/** This traversal specializes EulerTour to print out the expression
  * stored in an arithmetic expression tree. It assumes that method
  * toString, when called on a node v, prints the value stored at v if
  * v is external and the operator stored at v, if v is internal.  */
public class PrintExpressionTour extends EulerTour {
  public Object execute(BinaryTree T) {
    System.out.print("Expression: ");
    return null;   // nothing interesting to return
  protected void visitLeft(Position v, TraversalResult r) { 
    if (tree.isInternal(v)) System.out.print("("); }
  protected void visitBelow(Position v, TraversalResult r) { 
    System.out.print(v.element()); }
  protected void visitRight(Position v, TraversalResult r) { 
    if (tree.isInternal(v)) System.out.print(")"); }