I\'ve got an extremely long XML file, like
context1 test1
Your xml and question are kind of unclear, but what you're looking for is commonly called the Muenchian Grouping method - it's another way of asking for distinct nodes. With the appropriate keys this can be done very efficiently.