m_lastFetched = pos;
  public Node nextNode() throws DOMException  {    // If the cache is on, and the node has already been found, then     // just return from the list.    if ((null != m_cachedNodes)            && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))    {      Node next = m_cachedNodes.nextNode();      this.setCurrentPos(m_cachedNodes.getCurrentPos());      return next;    }    if (m_foundLast)      return null;    Node pos;  // our main itteration node.      boolean getSelf;    // Figure out what the start context should be.    // If the m_lastFetched is null at this point we're at the start     // of a fresh iteration.    if (null == m_lastFetched)    {      getSelf = m_orSelf; // true if descendants-or-self.            // The start context can either be the location path context node,       // or the root node.      if (getSelf && m_fromRoot)      {        if(m_context.getNodeType() == Node.DOCUMENT_NODE)          pos = m_context;        else          pos = m_context.getOwnerDocument();      }      else        pos = m_context;      m_startContext = pos;      resetProximityPositions();    }    else    {      // if the iterator is not fresh...      pos = m_lastFetched;      getSelf = false;  // never process the start node at this point.    }        org.apache.xpath.VariableStack vars;    int savedStart;    if (-1 != m_varStackPos)    {      vars = m_execContext.getVarStack();      // These three statements need to be combined into one operation.      savedStart = vars.getSearchStart();      vars.setSearchStart(m_varStackPos);      vars.pushContextPosition(m_varStackContext);    }    else    {      // Yuck.  Just to shut up the compiler!      vars = null;      savedStart = 0;    }        try    {      Node top = m_startContext; // tells us when to stop.      Node next = null;        // non-recursive depth-first traversal.      while (null != pos)      {        if(getSelf)        {          if(NodeFilter.FILTER_ACCEPT == acceptNode(pos))          {            next = pos;            break;          }        }        else          getSelf = true;                 Node nextNode = pos.getFirstChild();          while (null == nextNode)        {          if (top.equals(pos))            break;            nextNode = pos.getNextSibling();            if (null == nextNode)          {            pos = pos.getParentNode();              if ((null == pos) || (top.equals(pos)))            {              nextNode = null;                break;            }          }        }          pos = nextNode;      }            m_lastFetched = next;        if (null != next)      {        if (null != m_cachedNodes)          m_cachedNodes.addElement(next);          m_next++;          return next;      }      else      {        m_foundLast = true;        m_startContext = null;          return null;      }    }    finally    {      if (-1 != m_varStackPos)      {        // These two statements need to be combined into one operation.        vars.setSearchStart(savedStart);        vars.popContextPosition();      }    }  }