if (other.getImplementationType() != NodeValue.PERSISTENT_NODE) throw new XPathException("cannot compare persistent node with in-memory node"); NodeProxy node = (NodeProxy) other; if (doc.docId != node.doc.docId) return false;  int la = doc.getTreeLevel(gid); int lb = doc.getTreeLevel(node.gid); long pa = gid, pb = node.gid; if (la > lb) { while (la > lb) { pa = XMLUtil.getParentId(doc, pa, la); --la; } if (pa == pb) return true; else return pa > pb; } else if (lb > la) { while (lb > la) { pb = XMLUtil.getParentId(node.doc, pb, lb); --lb; } if (pb == pa) return false; else return pa > pb; } else return pa > pb;
return after(other, true);
	public boolean after(NodeValue other) throws XPathException {		if (other.getImplementationType() != NodeValue.PERSISTENT_NODE)			throw new XPathException("cannot compare persistent node with in-memory node");		NodeProxy node = (NodeProxy) other;		if (doc.docId != node.doc.docId)			return false;		//		System.out.println(gid + " >> " + node.gid);		int la = doc.getTreeLevel(gid);		int lb = doc.getTreeLevel(node.gid);		long pa = gid, pb = node.gid;		if (la > lb) {			while (la > lb) {				pa = XMLUtil.getParentId(doc, pa, la);				--la;			}			if (pa == pb)				return true;			else				return pa > pb;		} else if (lb > la) {			while (lb > la) {				pb = XMLUtil.getParentId(node.doc, pb, lb);				--lb;			}			if (pb == pa)				return false;			else				return pa > pb;		} else			return pa > pb;	}