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;
}

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 ; }
converts an iterator to a set of nodes , according to the xpath data model .
