synchronized Object iteratorFind(
                                    DeleteStack       stack,
                                    SearchComparator  comp,
                                    Object            searchKey,
                                    SearchNode        point)
    {
        point.reset();
        GBSNode p = root();
        GBSNode l = null;
        GBSNode r = null;
        int lx = 0;
        int rx = 0;
        Object ret = null;
        stack.start(dummyTopNode(), "GBSTree.iteratorFind");

        while (p != null)
        {
            int xcc = comp.compare(searchKey, p.middleKey());
            if (xcc == 0)
            {
                point.setFound(p, p.middleIndex());
                p = null;
            }
            else if (xcc < 0)
            {
                if (p.leftChild() != null)
                {
                    stack.push(NodeStack.PROCESS_CURRENT, p, "GBSTree.iteratorFind(1)");
                    l = p;
                    lx = stack.index();
                    p = p.leftChild();
                }
                else
                {
                    leftSearch(comp, p, r, searchKey, point);
                    if (point.wasFound())
                    {
                        if (point.foundNode() == r)
                            stack.reset(rx - 1);
                    }
                    p = null;
                }
            }
            else // (xcc > 0)
            {
                if (p.rightChild() != null)
                {
                    stack.push(NodeStack.DONE_VISITS, p, "GBSTree.iteratorFind(2)");
                    r = p;
                    rx = stack.index();
                    p = p.rightChild();
                }
                else
                {
                    rightSearch(comp, p, l, searchKey, point);
                    if (point.wasFound())
                    {
                        if (point.foundNode() == l)
                            stack.reset(lx - 1);
                    }
                    p = null;
                }
            }
        }

        if (point.wasFound())
        {
            ret = point.foundNode().key(point.foundIndex());
            point.setLocation(ret);
        }

        return ret;
    }
synchronized Object iteratorFind ( DeleteStack stack , SearchComparator comp , Object searchKey , SearchNode point ) { point . reset ( ) ; GBSNode p = root ( ) ; GBSNode l = null ; GBSNode r = null ; int lx = 0 ; int rx = 0 ; Object ret = null ; stack . start ( dummyTopNode ( ) , "GBSTree.iteratorFind" ) ; while ( p != null ) { int xcc = comp . compare ( searchKey , p . middleKey ( ) ) ; if ( xcc == 0 ) { point . setFound ( p , p . middleIndex ( ) ) ; p = null ; } else if ( xcc < 0 ) { if ( p . leftChild ( ) != null ) { stack . push ( NodeStack . PROCESS_CURRENT , p , "GBSTree.iteratorFind(1)" ) ; l = p ; lx = stack . index ( ) ; p = p . leftChild ( ) ; } else { leftSearch ( comp , p , r , searchKey , point ) ; if ( point . wasFound ( ) ) { if ( point . foundNode ( ) == r ) stack . reset ( rx - 1 ) ; } p = null ; } } else { if ( p . rightChild ( ) != null ) { stack . push ( NodeStack . DONE_VISITS , p , "GBSTree.iteratorFind(2)" ) ; r = p ; rx = stack . index ( ) ; p = p . rightChild ( ) ; } else { rightSearch ( comp , p , l , searchKey , point ) ; if ( point . wasFound ( ) ) { if ( point . foundNode ( ) == l ) stack . reset ( lx - 1 ) ; } p = null ; } } } if ( point . wasFound ( ) ) { ret = point . foundNode ( ) . key ( point . foundIndex ( ) ) ; point . setLocation ( ret ) ; } return ret ; }
Search the index from an Iterator.

<p>Search the index to find one of the following:</p>
<ol>
<li>An index entry that is exactly equal to the supplied key,
<li>An index entry that is strictly greater than the supplied key, or
<li>An index entry that is greater than or equal to the supplied key.
</ol>

<p>This is called by the Iterator when the tree has had structural
modifications between calls to next().  The only safe way to
re-establish the position of the Iterator is to re-search the
tree.  If this is a next() operation then the Iterator is searching
for the key that is greater than the last key given out.</p>