question: static Set < Node > toNodeSet ( Iterator < Node > i ) { Set < Node > nodeSet = new HashSet < Node > ( ) ; while ( i . hasNext ( ) ) { Node n = i . next ( ) ; nodeSet . add ( n ) ; if ( n . getNodeType ( ) == Node . ELEMENT_NODE ) { NamedNodeMap nnm = n . getAttributes ( ) ; for ( int j = 0 , length = nnm . getLength ( ) ; j < length ; j ++ ) { nodeSet . add ( nnm . item ( j ) ) ; } } } return nodeSet ; }
target:  Converts an Iterator to a Set of Nodes, according to the XPath Data Model.