code: private GBSNode nextNode(
                              DeleteStack    stack)
      {
          if (_eof)
              throw new RuntimeException("_eof is set on entry to nextNode()");
  
          boolean done = false;
          GBSNode q = null;
          GBSNode nextp = null;
          while ( !done )
          {
              if (stack.index() > GBSTree.maxDepth)
                  throw new OptimisticDepthException(
                                                    "maxDepth (" + GBSTree.maxDepth +
                                                    ") exceeded in GBSIterator.nextNode().");
              switch (_s)
              {
              case NodeStack.VISIT_LEFT:
                  _s = NodeStack.PROCESS_CURRENT;
                  q = _p.leftChild();
                  while (q != null)
                  {
                      stack.push(_s, _p, "GBSIterator.nextNode:VISIT_LEFT");
                      _p = q;
                      q = _p.leftChild();
                  }
                  break;
              case NodeStack.PROCESS_CURRENT:
                  _s = NodeStack.VISIT_RIGHT;
                  done = true;
                  nextp = _p;              /* Next node to visit                    */
                  break;
              case NodeStack.VISIT_RIGHT:
                  _s = NodeStack.DONE_VISITS;
                  q = _p.rightChild();
                  if (q != null)
                  {
                      stack.push(_s, _p, "GBSIterator.nextNode:VISIT_RIGHT");
                      _s = NodeStack.VISIT_LEFT;
                      _p = _p.rightChild();
                  }
                  break;
              case NodeStack.DONE_VISITS:
                  if (stack.index() <= 0)  /* Have finally hit end of sub-tree      */
                      done = true;
                  else
                  {
                      _s = stack.state();
                      _p = stack.node();
                      stack.pop();
                  }
                  break;
              default:
                  throw new RuntimeException("Help!, _s = " + _s + ", _p = " + _p + ".");
              }                            /* switch(_s)                            */
          }                              /* while ( !done )                       */
          return nextp;
      }
docs: Find the next node in the tree in key order.
  
  @param stack The stack being used for traversal.
  
  @return the next node in key order.  null if we have reached the end.