/**
   * Internal method to find an item in a subtree.
   *
   * @param x is item to search for.
   * @param t the node that roots the tree.
   * @return node containing the matched item.
   */
  private BinaryNode<AnyType> find(AnyType x, BinaryNode<AnyType> t) {

    while (t != null) {

      if (x.compareTo(t.element) < 0) t = t.left;
      else if (x.compareTo(t.element) > 0) t = t.right;
      else {
        t.wasFound = true;
        return t; // Match
      }
    }

    return null; // Not found
  }