code: public int nextNode()
    {
    	if(m_foundLast)
    		return DTM.NULL;
  
      // If the variable stack position is not -1, we'll have to 
      // set our position in the variable stack, so our variable access 
      // will be correct.  Iterators that are at the top level of the 
      // expression need to reset the variable stack, while iterators 
      // in predicates do not need to, and should not, since their execution
      // may be much later than top-level iterators.  
      // m_varStackPos is set in setRoot, which is called 
      // from the execute method.
      if (-1 == m_stackFrame)
      {
        return returnNextNode(m_firstWalker.nextNode());
      }
      else
      {
        VariableStack vars = m_execContext.getVarStack();
  
        // These three statements need to be combined into one operation.
        int savedStart = vars.getStackFrame();
  
        vars.setStackFrame(m_stackFrame);
  
        int n = returnNextNode(m_firstWalker.nextNode());
  
        // These two statements need to be combined into one operation.
        vars.setStackFrame(savedStart);
  
        return n;
      }
    }
docs: Returns the next node in the set and advances the position of the
  iterator in the set. After a NodeIterator is created, the first call
  to nextNode() returns the first node in the set.
  @return  The next <code>Node</code> in the set being iterated over, or
  <code>null</code> if there are no more members in that set.