public void traverseInOrder() {
   ThreadedBinaryNode<T> t = firstInOrderNode();
   while (t != null) {
     System.out.println(t);
     t = t.inOrderSuccessor();
   }
 }
 public void traverseInOrderBackwards() {
   ThreadedBinaryNode<T> t = lastInOrderNode();
   while (t != null) {
     System.out.println(t);
     t = t.inOrderPredecessor();
   }
 }
 void insert(T x, ThreadedBinaryNode<T> t) throws DuplicateItem {
   if (x.compareTo(t.element) < 0)
     if (t.isLeftThread) {
       t.left = new ThreadedBinaryNode(x, t.left, t);
       t.isLeftThread = false;
     } else insert(x, t.left);
   else if (x.compareTo(t.element) > 0)
     if (t.isRightThread) {
       t.right = new ThreadedBinaryNode(x, t, t.right);
       t.isRightThread = false;
     } else insert(x, t.right);
   else throw new DuplicateItem("attempt to insert duplicateitem");
 }