presto-main/src/main/java/io/prestosql/execution/resourcegroups/StochasticPriorityQueue.java/StochasticPriorityQueue/remove
class StochasticPriorityQueue:    @Override
    public boolean remove(E element)
    {
        Node<E> node = index.remove(element);
        if (node == null) {
            return false;
        }
        if (node.isLeaf() && node.equals(root)) {
            root = null;
        }
        else if (node.isLeaf()) {
            node.remove();
        }
        else {
            // This is an intermediate node.  Instead of removing it directly, remove a leaf
            // and then replace the data in this node with the data in the leaf.  This way
            // we don't have to reorganize the tree structure.
            Node<E> leaf = root.findLeaf();
            leaf.remove();
            node.setTickets(leaf.getTickets());
            node.setValue(leaf.getValue());
            index.put(leaf.getValue(), node);
        }
        return true;
    }