pb = pb.getParentId();  cmp = pa.compareTo(pb); if(cmp == 0) { if(mode == NodeSet.DESCENDANT) { if (Expression.NO_CONTEXT_ID != contextId) nb.addContextNode(contextId, na); else nb.copyContext(na); result.add(nb); } else { if (Expression.NO_CONTEXT_ID != contextId) na.addContextNode(contextId, nb); else na.copyContext(nb); result.add(na); }
System.out.println(pa + " -> " + pb);  if (pb.isDescendantOf(pa)) { if (pb.isChildOf(pa)) { if(mode == NodeSet.DESCENDANT) { if (Expression.NO_CONTEXT_ID != contextId) nb.addContextNode(contextId, na); else nb.copyContext(na); result.add(nb); } else { if (Expression.NO_CONTEXT_ID != contextId) na.addContextNode(contextId, nb); else na.copyContext(nb); result.add(na); } }
	public NodeSet quickSelectParentChild(NodeSet al, int mode, int contextId) {	    final NodeSet result = new ExtArrayNodeSet();		final Iterator ia = al.iterator();		final Iterator ib = iterator();//		final long start = System.currentTimeMillis();		NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next();				// check if one of the node sets is empty		if(na == null || nb == null)		    return result;		NodeId pa, pb;		int cmp;		while (true) {			// first, try to find nodes belonging to the same doc			if (na.getDocument().getDocId() < nb.getDocument().getDocId()) {				if (ia.hasNext())					na = (NodeProxy) ia.next();				else					break;			} else if (na.getDocument().getDocId() > nb.getDocument().getDocId()) {				if (ib.hasNext())					nb = (NodeProxy) ib.next();				else					break;			} else {			    // same document			    pa = na.getNodeId();			    pb = nb.getNodeId();//			    System.out.println(pa + " -> " + pb);			    pb = pb.getParentId();//				System.out.println("comparing " + pa + " -> " + pb);			    cmp = pa.compareTo(pb);				if(cmp == 0) {				    if(mode == NodeSet.DESCENDANT) {				        if (Expression.NO_CONTEXT_ID != contextId)				            nb.addContextNode(contextId, na);				        else				            nb.copyContext(na);				        result.add(nb);				    } else {				        if (Expression.NO_CONTEXT_ID != contextId)				            na.addContextNode(contextId, nb);				        else				            na.copyContext(nb);				        result.add(na);				    }				    if (ib.hasNext())						nb = (NodeProxy) ib.next();					else						break;				} else if (cmp < 0) {					if (ia.hasNext())						na = (NodeProxy) ia.next();					else						break;				} else {					if (ib.hasNext())						nb = (NodeProxy) ib.next();					else						break;				}			}		}//		LOG.debug("quickSelect took " + (System.currentTimeMillis() - start));		return result;	}