@Override
    public V add(K key, V value)
    {
        if (key == null || value == null)
        {
            throw new IllegalArgumentException();
        }
        if (root == null)
        {
            root = new Node<K, V>(key, value);
            return null;
        }
        Stack<Node<K, V>> stack = new ArrayList<Node<K, V>>();
        Node<K, V> node = root;
        while (node != null)
        {
            stack.push(node);
            int c = key.compareTo(node.key);
            if (c < 0)
            {
                if (node.less == null)
                {
                    node.less = new Node<K, V>(key, value);
                    break;
                }
                node = node.less;
            }
            else if (c > 0)
            {
                if (node.greater == null)
                {
                    node.greater = new Node<K, V>(key, value);
                    break;
                }
                node = node.greater;
            }
            else
            {
                V old = node.value;
                node.value = value;
                return old;
            }
        }
        while (!stack.empty())
        {
            node = stack.pop();
            ++node.size;
        }
        return null;
    }