public RBBranch(T value, RBBranch <T> parent)
 {
     this.parent = parent;
     this.value  = value;
     red         = true;
     left        = new RBLeaf <T> (this);
     right       = new RBLeaf <T> (this);
 }
 void Insert(RBBranch <T> node)
 {
     root.Insert(node);
     node.InsertRepair();
     root = node;
     while (root.parent != null)
     {
         root = root.parent;
     }
 }
 void ReplaceNode(RBNode <T> child)
 {
     child.parent = parent;
     if (parent != null)
     {
         if (this == parent.left)
         {
             parent.left = child;
         }
         else
         {
             parent.right = child;
         }
     }
 }
        public void Remove(T value)
        {
            root.Remove(value);

            RBBranch <T> rootBranch = (RBBranch <T>)root;

            if (rootBranch.left.parent == null)
            {
                root = rootBranch.left;
            }
            else if (rootBranch.right.parent == null)
            {
                root = rootBranch.right;
            }
            while (root.parent != null)
            {
                root = root.parent;
            }
        }
 public RBTree()
 {
     root = new RBLeaf <T> ();
 }