code: private UpdateResult delete(long key, Node node) {
          UpdateResult result;
          if (node == null) {
              // Item not found.
              result = new UpdateResult();
          } else {
              long itemKey = node.item.key();
              if (key < itemKey) {
                  // Given key is smaller than the current node's item key; proceed to the node's left child.
                  result = delete(key, node.left);
                  node.left = result.node;
              } else if (key > itemKey) {
                  // Given key is larger than the current node's item key; proceed to the node's right child.
                  result = delete(key, node.right);
                  node.right = result.node;
              } else {
                  // Found the node. Remember it's item.
                  result = new UpdateResult();
                  result.updatedItem = node.item;
                  if (node.left != null && node.right != null) {
                      // The node has two children. Replace the node's item with its in-order successor, and then remove
                      // that successor's node.
                      node.item = findSmallest(node.right);
                      node.right = delete(node.item.key(), node.right).node;
                  } else {
                      // The node has just one child. Replace it with that child.
                      node = (node.left != null) ? node.left : node.right;
                      this.size--;
                      this.modCount++;
                  }
              }
  
              // Rebalance the sub-tree, if necessary.
              result.node = balance(node);
          }
  
          return result;
      }
docs: Removes an item with given key from a subtree.
  
  @param key  The Key to remove.
  @param node The node at the root of the subtree.
  @return The new root of the subtree.