private void collapse(Stack<Node<V>> nodes)
    {
        while (!nodes.empty())
        {
            Node<V> node = nodes.pop();
            if (node.value != null || node.less != null || node.equal != null || node.greater != null)
            {
                break;
            }
            if (nodes.empty())
            {
                root = null;
            }
            else
            {
                remove(nodes.top(), node);
            }
        }
    }