}
  public int nextNode()  {    // If the cache is on, and the node has already been found, then     // just return from the list.    // If the cache is on, and the node has already been found, then     // just return from the list.    if ((null != m_cachedNodes)            && (m_next < m_cachedNodes.size()))    {      int next = m_cachedNodes.elementAt(m_next);          incrementNextPosition();      m_currentContextNode = next;      return next;    }    if (m_foundLast)      return DTM.NULL;          if(DTM.NULL == m_lastFetched)    {      resetProximityPositions();    }    int next;        org.apache.xpath.VariableStack vars;    int savedStart;    if (-1 != m_stackFrame)    {      vars = m_execContext.getVarStack();      // These three statements need to be combined into one operation.      savedStart = vars.getStackFrame();      vars.setStackFrame(m_stackFrame);    }    else    {      // Yuck.  Just to shut up the compiler!      vars = null;      savedStart = 0;    }        try    {      do      {        if(0 == m_extendedTypeID)        {          next = m_lastFetched = (DTM.NULL == m_lastFetched)                       ? m_traverser.first(m_context)                       : m_traverser.next(m_context, m_lastFetched);        }        else        {          next = m_lastFetched = (DTM.NULL == m_lastFetched)                       ? m_traverser.first(m_context, m_extendedTypeID)                       : m_traverser.next(m_context, m_lastFetched,                                           m_extendedTypeID);        }          if (DTM.NULL != next)        {          if(DTMIterator.FILTER_ACCEPT == acceptNode(next))            break;          else            continue;        }        else          break;      }      while (next != DTM.NULL);        if (DTM.NULL != next)      {        if (null != m_cachedNodes)          m_cachedNodes.addElement(m_lastFetched);          m_next++;          return next;      }      else      {        m_foundLast = true;          return DTM.NULL;      }    }    finally    {      if (-1 != m_stackFrame)      {        // These two statements need to be combined into one operation.        vars.setStackFrame(savedStart);      }    }  }