parent.addContextNode(contextId, array[i]);
parent.deepCopyContext(array[i], contextId);
        NodeSet getChildrenInSet(NodeSet result, NodeProxy parent, int mode, int contextId) {            // get the range of node ids reserved for children of the parent            // node            Range range = NodeSetHelper.getChildRange(parent.getDocument(), parent.getGID());            int low = 0;            int high = length - 1;            int mid = 0;            NodeProxy p;            // do a binary search to pick some node in the range of valid child            // ids            while (low <= high) {                mid = (low + high) / 2;                p = array[mid];                if (range.inRange(p.getGID()))                    break; // found a node, break out                if (p.getGID() > range.getStart())                    high = mid - 1;                else                    low = mid + 1;            }            if (low > high)                return result; // no node found            // find the first child node in the range            while (mid > 0 && array[mid - 1].getGID() >= range.getStart())                --mid;            // walk through the range of child nodes we found            for (int i = mid; i < length && array[i].getGID() <= range.getEnd(); i++) {                switch (mode) {                    case NodeSet.DESCENDANT :                        if (Expression.NO_CONTEXT_ID != contextId)                            array[i].addContextNode(contextId, parent);                        else                            array[i].copyContext(parent);                        array[i].addMatches(parent);                        result.add(array[i], range.getDistance());                        break;                    case NodeSet.ANCESTOR :                        if (Expression.NO_CONTEXT_ID != contextId)                            parent.addContextNode(contextId, array[i]);                        else                            parent.copyContext(array[i]);                        parent.addMatches(array[i]);                        result.add(parent, 1);                        break;                }            }            return result;        }