current = (ret == null) ? current : ret;
  public Node nextNode()    throws DOMException  {    if (root == null)      {        throw new DOMException(DOMException.INVALID_STATE_ERR, "null root");      }    Node ret;    do      {        if (current.equals(root))          {            ret = root.getFirstChild();          }        else if (walk)          {            ret = current.getFirstChild();            if (ret == null)              {                ret = current.getNextSibling();              }            if (ret == null)              {                Node tmp = current;                ret = tmp.getParentNode();                while (!ret.equals(root) && tmp.equals(ret.getLastChild()))                  {                    tmp = ret;                    ret = tmp.getParentNode();                  }                if (ret.equals(root))                  {                    ret = null;                  }                else                  {                    ret = ret.getNextSibling();                  }              }          }        else          {            ret = current.getNextSibling();          }      }    while (!accept(ret));    current = (ret == null) ? current : ret;    return ret;  }