/** Returns the root of the tree. */
  public Position root() throws EmptyTreeException {
    if (root == null)
      throw new EmptyTreeException("The tree has no root");
    return root;
  } 
  /** Returns the left child of a node. */
  public Position left(Position v) 
    throws InvalidPositionException, BoundaryViolationException { 
    if (!hasLeft(v))
      throw new BoundaryViolationException("No left child");
    return ((BTPosition)v).getLeft();
  }
  /** Returns the right child of a node. */
  public Position right(Position v) 
    throws InvalidPositionException, BoundaryViolationException { 
    if (!hasRight(v))
      throw new BoundaryViolationException("No right child");
    return ((BTPosition)v).getRight(); 
  }
  /** Returns the parent of a node. */
  public Position parent(Position v) 
    throws InvalidPositionException, BoundaryViolationException { 
    if (isRoot(v))
      throw new BoundaryViolationException("Root has no parent");
    return ((BTPosition)v).getParent(); 
  }
  /** Returns an iterator of the children of a node. */
  public Iterator children(Position v) 
    throws InvalidPositionException { 
    List children = new NodeList();
    if (hasLeft(v))
      children.insertLast(left(v));
    if (hasRight(v))
      children.insertLast(right(v));
    return children.elements();
  }
  /** Returns an iterator of the tree nodes. */
  public Iterator positions() {
    List positions = new NodeList();
    if(size != 0)
      inorderPositions(root(), positions);  // assign positions in inorder
    return positions.elements();
  }