/// <summary>
        /// Returns the iterator pointing to the first item greater than <paramref name="item"/>.
        /// </summary>
        public RedBlackTreeIterator <T> UpperBound(T item)
        {
            RedBlackTreeIterator <T> it = LowerBound(item);

            while (it.IsValid && _host.Compare(it.Current, item) == 0)
            {
                it.MoveNext();
            }
            return(it);
        }
        public bool Remove(T item)
        {
            RedBlackTreeIterator <T> it = Find(item);

            if (!it.IsValid)
            {
                return(false);
            }
            else
            {
                RemoveAt(it);
                return(true);
            }
        }
        /// <summary>
        /// Returns the iterator pointing to the specified item, or an iterator in End state if the item is not found.
        /// </summary>
        public RedBlackTreeIterator <T> Find(T item)
        {
            RedBlackTreeIterator <T> it = LowerBound(item);

            while (it.IsValid && _host.Compare(it.Current, item) == 0)
            {
                if (_host.Equals(it.Current, item))
                {
                    return(it);
                }
                it.MoveNext();
            }
            return(default(RedBlackTreeIterator <T>));
        }
        public void RemoveAt(RedBlackTreeIterator <T> iterator)
        {
            RedBlackTreeNode <T> node = iterator.Node;

            if (node == null)
            {
                throw new ArgumentException("Invalid iterator");
            }
            while (node.Parent != null)
            {
                node = node.Parent;
            }
            if (node != Root)
            {
                throw new ArgumentException("Iterator does not belong to this tree");
            }
            RemoveNode(iterator.Node);
#if DEBUG
            CheckProperties();
#endif
        }