code: public int getLastPos(XPathContext xctxt)
    {
  
      int pos = getProximityPosition();
      
      AxesWalker walker;
  
      try
      {
        walker = (AxesWalker) clone();
      }
      catch (CloneNotSupportedException cnse)
      {
        return -1;
      }
  
      walker.setPredicateCount(m_predicateIndex);
      walker.setNextWalker(null);
      walker.setPrevWalker(null);
  
      WalkingIterator lpi = wi();
      AxesWalker savedWalker = lpi.getLastUsedWalker();
  
      try
      {
        lpi.setLastUsedWalker(walker);
  
        int next;
  
        while (DTM.NULL != (next = walker.nextNode()))
        {
          pos++;
        }
  
        // TODO: Should probably save this in the iterator.
      }
      finally
      {
        lpi.setLastUsedWalker(savedWalker);
      }
  
      // System.out.println("pos: "+pos);
      return pos;
    }
docs: Get the index of the last node that can be itterated to.
  
  
  @param xctxt XPath runtime context.
  
  @return the index of the last node that can be itterated to.