code: private void deleteEntry(TreeEntry<E> p) {
          entryIDs.remove(p.value.getId());
  
          treeSize--;
  
          // If strictly internal, copy successor's element to p and then make p
          // point to successor.
          if (p.left != null && p.right != null) {
              TreeEntry<E> s = successor(p);
              p.low = s.low;
              p.high = s.high;
              p.value = s.value;
              p.maxHigh = s.maxHigh;
              p = s;
          }      // p has 2 children
  
          // Start fixup at replacement node, if it exists.
          TreeEntry<E> replacement = p.left != null ? p.left : p.right;
  
          if (replacement != null) {
              // Link replacement to parent
              replacement.parent = p.parent;
              if (p.parent == null) {
                  root = replacement;
              } else if (p == p.parent.left) {
                  p.parent.left = replacement;
              } else {
                  p.parent.right = replacement;
              }
  
              // Null out links so they are OK to use by fixAfterDeletion.
              p.left = null;
              p.right = null;
              p.parent = null;
  
              fixUpMaxHigh(replacement.parent); // augmented interval tree
  
              // Fix replacement
              if (p.color == BLACK) {
                  fixAfterDeletion(replacement);
              }
          } else if (p.parent == null) { // return if we are the only node.
              root = null;
          } else { // No children. Use self as phantom replacement and unlink.
              if (p.color == BLACK) {
                  fixAfterDeletion(p);
              }
  
              if (p.parent != null) {
                  if (p == p.parent.left) {
                      p.parent.left = null;
                  } else if (p == p.parent.right) {
                      p.parent.right = null;
                  }
  
                  fixUpMaxHigh(p.parent); // augmented interval tree
  
                  p.parent = null;
              }
          }
      }
docs: Delete node p, and then rebalance the tree.