@Override
    public void delete(Key key) {
        Node x = this.root;
        Node parent = x, temp;

        temp = x;

        while (x != null) {
            int cmp = key.compareTo(x.key);

            if (cmp < 0)
                x = x.left;
            else if (cmp > 0)
                x = x.right;
            else {
                if (isLeaf(x)) {
                    if (parent.right != null && parent.right.equals(x))
                        parent.right = null;
                    else if (parent.left != null && parent.left.equals(x))
                        parent.left = null;
                    else if (parent.equals(x))
                        root = null;

                }
            }
            parent = temp;
        }
    }