code: private int tryRemove(int node)
      {
          checkArgument(node != -1, "node is -1");
  
          int left = lefts[node];
          int right = rights[node];
  
          if (left == -1 && right == -1) {
              // leaf, just remove it
              remove(node);
              return -1;
          }
  
          if (left != -1 && right != -1) {
              // node has both children so we can't physically remove it
              counts[node] = 0;
              return node;
          }
  
          // node has a single child, so remove it and return the child
          remove(node);
          if (left != -1) {
              return left;
          }
          else {
              return right;
          }
      }
docs: Remove the node if possible or set its count to 0 if it has children and
  it needs to be kept around