Delete node p, and then rebalance the tree.
340351
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;
            }
        }
    }
304176
public void remove(int node) {
        if (node == NIL) {
            throw new IllegalArgumentException();
        }
        if (left(node) != NIL && right(node) != NIL) {
            // inner node
            final int next = next(node);
            assert next != NIL;
            swap(node, next);
        }
        assert left(node) == NIL || right(node) == NIL;

        final int parent = parent(node);
        int child = left(node);
        if (child == NIL) {
            child = right(node);
        }

        if (child == NIL) {
            // no children
            if (node == root) {
                assert size() == 1 : size();
                root = NIL;
            } else {
                if (node == left(parent)) {
                    left(parent, NIL);
                } else {
                    assert node == right(parent);
                    right(parent, NIL);
                }
            }
        } else {
            // one single child
            if (node == root) {
                assert size() == 2;
                root = child;
            } else if (node == left(parent)) {
                left(parent, child);
            } else {
                assert node == right(parent);
                right(parent, child);
            }
            parent(child, parent);
        }

        release(node);
        rebalance(parent);
    }
371161
private synchronized void rebalanceJobNode(List<String> nodes) {
		while(updatingStatus);
		Collection<JobConfig> jobs = schedulerConfgs.values();
		int nodeIndex = 0;
		for (JobConfig job : jobs) {
			String nodeId = nodes.get(nodeIndex++);
			if(!StringUtils.equals(job.getCurrentNodeId(), nodeId)){				
				job.setCurrentNodeId(nodeId);
				logger.info("rebalance Job[{}-{}] To Node[{}] ",job.getGroupName(),job.getJobName(),nodeId);
			}
			if(nodeIndex >= nodes.size()){
				nodeIndex = 0;
			}
			//
			updateJobConfig(job);
		}
		
	}
7955
function(oldNode){
      var nodes = this.nodes;
      if (arrayRemove(nodes, oldNode))
      {
        this.first = nodes[0] || null;
        this.last = nodes[nodes.length - 1] || null;
        oldNode.groupNode = null;

        this.emit_childNodesModified({ deleted: [oldNode] });
      }

      if (!this.first && this.autoDestroyIfEmpty)
        this.destroy();
    }
193979
private void deleteEntry(TreeMapEntry<K,V> p) {
        modCount++;
        size--;

        // If strictly internal, copy successor's element to p and then make p
        // point to successor.
        if (p.left != null && p.right != null) {
            TreeMapEntry<K,V> s = successor(p);
            p.key = s.key;
            p.value = s.value;
            p = s;
        } // p has 2 children

        // Start fixup at replacement node, if it exists.
        TreeMapEntry<K,V> 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 = p.right = p.parent = null;

            // 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;
                p.parent = null;
            }
        }
    }
345465
function rebalanceAlongPath(node, path) {
		var newRoot = node, 
			rotated, i;
		if (!node.hasOwnProperty('key')) { delete node.height; return node; }   // Empty tree
		// Rebalance the tree and update all heights
		for (i = path.length - 1; i >= 0; i -= 1) {
			path[i].height = 1 + Math.max(path[i].left ? path[i].left.height : 0, path[i].right ? path[i].right.height : 0);
			if (balanceFactor(path[i]) > 1) {
				rotated = rightTooSmall(path[i]);
				if (i === 0) { newRoot = rotated; }
			}
			if (balanceFactor(path[i]) < -1) {
				rotated = leftTooSmall(path[i]);
				if (i === 0) { newRoot = rotated; }
			}
		}
		return newRoot;
	}
1011420
private RedBlackTreeNode<Key, Value> deleteMin(RedBlackTreeNode<Key, Value> h) {
	if (h.getLeft() == null)
	    return null;

	if (!isRed(h.getLeft()) && !isRed(h.getLeft().getLeft()))
	    h = moveRedLeft(h);

	h.setLeft(deleteMin(h.getLeft()));
	return balance(h);
    }
455115
function clear(node){
    node = get(node);

    while (node[LAST_CHILD])
      node.removeChild(node[LAST_CHILD]);

    return node;
  }
1112205
function( nodeStructure, id, parentId, tree, stackParentId ) {
        this.reset( nodeStructure, id, parentId, tree, stackParentId );
    }
313024
def clear(self):
        """"""
        node = self._first
        while node is not None:
            next_node = node._next
            node._list = node._prev = node._next = None
            node = next_node
        self._size = 0
83434
def _flag_node_as_del_and_del_in_by_target(self, node_id):
        """"""
        self.nodes_deleted.append(node_id)
        etp = self._edge_by_target.get(node_id)
        if etp is not None:
            del self._edge_by_target[node_id]
1154501
def _delete_node(self, tree, node):
        
        # Calculate gains
        temp_tree = copy.deepcopy(tree)

        def recourse(temp_tree_, del_node):
            if isinstance(temp_tree_, dict):
                if temp_tree_['split'] != -1:
                    if temp_tree_['node'] == del_node:
                        del temp_tree_['sr']
                        del temp_tree_['sl']
                        del temp_tree_['node']
                        temp_tree_['split'] = -1
                    else:
                        for k in ['sl', 'sr']:
                            recourse(temp_tree_[k], del_node)
            return None

        recourse(temp_tree, node)
        return temp_tree
1173797
private void rebalance(Node<K, V> unbalanced, boolean insert) {
    for (Node<K, V> node = unbalanced; node != null; node = node.parent) {
      Node<K, V> left = node.left;
      Node<K, V> right = node.right;
      int leftHeight = left != null ? left.height : 0;
      int rightHeight = right != null ? right.height : 0;

      int delta = leftHeight - rightHeight;
      if (delta == -2) {
        Node<K, V> rightLeft = right.left;
        Node<K, V> rightRight = right.right;
        int rightRightHeight = rightRight != null ? rightRight.height : 0;
        int rightLeftHeight = rightLeft != null ? rightLeft.height : 0;

        int rightDelta = rightLeftHeight - rightRightHeight;
        if (rightDelta == -1 || (rightDelta == 0 && !insert)) {
          rotateLeft(node); // AVL right right
        } else {
          assert (rightDelta == 1);
          rotateRight(right); // AVL right left
          rotateLeft(node);
        }
        if (insert) {
          break; // no further rotations will be necessary
        }

      } else if (delta == 2) {
        Node<K, V> leftLeft = left.left;
        Node<K, V> leftRight = left.right;
        int leftRightHeight = leftRight != null ? leftRight.height : 0;
        int leftLeftHeight = leftLeft != null ? leftLeft.height : 0;

        int leftDelta = leftLeftHeight - leftRightHeight;
        if (leftDelta == 1 || (leftDelta == 0 && !insert)) {
          rotateRight(node); // AVL left left
        } else {
          assert (leftDelta == -1);
          rotateLeft(left); // AVL left right
          rotateRight(node);
        }
        if (insert) {
          break; // no further rotations will be necessary
        }

      } else if (delta == 0) {
        node.height = leftHeight + 1; // leftHeight == rightHeight
        if (insert) {
          break; // the insert caused balance, so rebalancing is done!
        }

      } else {
        assert (delta == -1 || delta == 1);
        node.height = Math.max(leftHeight, rightHeight) + 1;
        if (!insert) {
          break; // the height hasn't changed, so rebalancing is done!
        }
      }
    }
  }
1099402
def trim_tree(self, node):
        """"""
        data_len = len(node[-1])

        if node[1] == -1 and node[2] == -1:
            if data_len == 0:
                return 1
            else:
                return 0
        else:
            if self.trim_tree(node[1]) == 1:
                node[1] = -1

            if self.trim_tree(node[2]) == 1:
                node[2] = -1

            if node[1] == -1 and node[2] == -1:
                if data_len == 0:
                    return 1
                else:
                    return 0
644458
def replacenode(self, othereplus, node):
        """"""
        node = node.upper()
        self.dt[node.upper()] = othereplus.dt[node.upper()]
756236
def delete(self):
        """"""
        stacks = [
            self.utilities_name,
            self.spot_nodes_name,
            self.node_group_name,
            self.cluster_name,
            self.vpc_name,
            self.role_name
        ]
        # Execute creation.
        for stack in tqdm.tqdm(stacks, ncols=70):
            self.delete_stack(stack)
243079
async def delete(self):
        """"""
        await self._handler.delete(
            system_id=self.node.system_id, id=self.id)