public Node<T> insert(T value)
    {
        if (root == null) {
            root = new Node<T>(value);
            return root;
        }
        Node<T> tree = root;
        while (true) {
            int cmp = value.compareTo(tree.data);
            if (cmp > 0) {
                if (tree.right == null) {
                    tree.setRight(new Node<T>(value));
                    return tree.right;
                }
                else {
                    tree = tree.right;
                }
            }
            else {
                if (tree.left == null) {
                    tree.setLeft(new Node<T>(value));
                    return tree.left;
                }
                else {
                    tree = tree.left;
                }
            }
        }
    }