public NodeProxy parentWithChild( DocumentImpl doc, long gid, boolean directParent, boolean includeSelf, int level) { NodeProxy temp; if (includeSelf && (temp = get(doc, gid)) != null) return temp; if (level < 0) level = doc.getTreeLevel(gid); while (gid > 0) { if (level == 0) gid = -1; else  gid = (gid - doc.treeLevelStartPoints[level]) / doc.treeLevelOrder[level] + doc.treeLevelStartPoints[level - 1]; if ((temp = get(doc, gid)) != null) return temp; else if (directParent) return null; else --level; } return null;
public NodeProxy parentWithChild(DocumentImpl doc, long gid, boolean directParent) { return parentWithChild(doc, gid, directParent, false, -1);
	public NodeProxy parentWithChild(		DocumentImpl doc,		long gid,		boolean directParent,		boolean includeSelf,		int level) {		NodeProxy temp;		if (includeSelf && (temp = get(doc, gid)) != null)			return temp;		if (level < 0)			level = doc.getTreeLevel(gid);		while (gid > 0) {			if (level == 0)				gid = -1;			else				// calculate parent's gid				gid =					(gid - doc.treeLevelStartPoints[level]) / doc.treeLevelOrder[level]						+ doc.treeLevelStartPoints[level						- 1];			if ((temp = get(doc, gid)) != null)				return temp;			else if (directParent)				return null;			else				--level;		}		return null;	}