public Element previous(){
  int stackSize;
  if (elementStack == null || (stackSize=elementStack.size()) == 0) {
    return null;
  }
  StackItem item=elementStack.peek();
  Element elem=item.getElement();
  int index=item.getIndex();
  if (index > 0) {
    return getDeepestLeaf(elem.getElement(--index));
  }
 else   if (index == 0) {
    return elem;
  }
 else   if (index == -1) {
    if (stackSize == 1) {
      return null;
    }
    StackItem top=elementStack.pop();
    item=elementStack.peek();
    elementStack.push(top);
    elem=item.getElement();
    index=item.getIndex();
    return ((index == -1) ? elem : getDeepestLeaf(elem.getElement(index)));
  }
  return null;
}

public Element previous ( ) { int stackSize ; if ( elementStack == null || ( stackSize = elementStack . size ( ) ) == 0 ) { return null ; } StackItem item = elementStack . peek ( ) ; Element elem = item . getElement ( ) ; int index = item . getIndex ( ) ; if ( index > 0 ) { return getDeepestLeaf ( elem . getElement ( -- index ) ) ; } else if ( index == 0 ) { return elem ; } else if ( index == - 1 ) { if ( stackSize == 1 ) { return null ; } StackItem top = elementStack . pop ( ) ; item = elementStack . peek ( ) ; elementStack . push ( top ) ; elem = item . getElement ( ) ; index = item . getIndex ( ) ; return ( ( index == - 1 ) ? elem : getDeepestLeaf ( elem . getElement ( index ) ) ) ; } return null ; }
fetches the previous element . if however the current element is the last element , or the current element is null , then null is returned .
