public Element first(){
  if (root == null) {
    return null;
  }
  elementStack=new Stack<StackItem>();
  if (root.getElementCount() != 0) {
    elementStack.push(new StackItem(root));
  }
  return root;
}

public Element first ( ) { if ( root == null ) { return null ; } elementStack = new Stack < StackItem > ( ) ; if ( root . getElementCount ( ) != 0 ) { elementStack . push ( new StackItem ( root ) ) ; } return root ; }
fetches the first element .
