public BinarySearchTreeNode Get(BinarySearchTreeNode currNode, int key)
 {
     if (currNode == null)
     {
         return(null);
     }
     else if (key.CompareTo(currNode.key) < 0)
     {
         return(Get(currNode.left, key));
     }
     else if (key.CompareTo(currNode.key) > 0)
     {
         return(Get(currNode.right, key));
     }
     else
     {
         return(currNode);
     }
 }
 public BinarySearchTreeNode Insert(BinarySearchTreeNode currNode, int key, int value)
 {
     if (currNode == null)
     {
         return(new BinarySearchTreeNode(key, value));
     }
     else if (key.CompareTo(currNode.key) < 0)
     {
         currNode.left = Insert(currNode.left, key, value);
     }
     else if (key.CompareTo(currNode.key) > 0)
     {
         currNode.right = Insert(currNode.right, key, value);
     }
     else
     {
         currNode.value = value;
     }
     currNode.count = CountOf(currNode.left) + CountOf(currNode.right) + 1;
     return(currNode);
 }
        public void NodesInRange(BinarySearchTreeNode currNode, int lo, int hi)
        {
            if (currNode == null)
            {
                return;
            }
            else if (lo.CompareTo(currNode.key) == 0 || hi.CompareTo(currNode.key) == 0)
            {
                if (lo.CompareTo(currNode.key) == 0)
                {
                    Console.Write(currNode.key);
                    Console.Write(" ");
                    NodesInRange(currNode.right, lo, hi);
                }

                else if (hi.CompareTo(currNode.key) == 0)
                {
                    Console.Write(currNode.key);
                    Console.Write(" ");
                    NodesInRange(currNode.left, lo, hi);
                }
            }
            else if (lo.CompareTo(currNode.key) > 0)
            {
                NodesInRange(currNode.right, lo, hi);
            }
            else if (hi.CompareTo(currNode.key) < 0)
            {
                NodesInRange(currNode.left, lo, hi);
            }
            else
            {
                Console.Write(currNode.key);
                Console.Write(" ");
                NodesInRange(currNode.left, lo, hi);
                NodesInRange(currNode.right, lo, hi);
            }
        }
 public BinarySearchTreeNode Insert(int key, int value)
 {
     root = Insert(root, key, value);
     return(root);
 }
 public BinarySearchTree()
 {
     root = null;
 }