presto-main/src/main/java/io/prestosql/execution/resourcegroups/StochasticPriorityQueue.java/StochasticPriorityQueue/findLeaf
class StochasticPriorityQueue:        public Node<E> findLeaf()
        {
            int leftDecendants = left.map(node -> node.descendants).orElse(0);
            int rightDecendants = right.map(node -> node.descendants).orElse(0);

            if (leftDecendants == 0 && rightDecendants == 0) {
                return left.orElse(right.orElse(this));
            }
            if (leftDecendants > rightDecendants) {
                return left.get().findLeaf();
            }
            if (rightDecendants > leftDecendants) {
                return right.get().findLeaf();
            }
            // For ties just go left
            checkState(left.isPresent(), "Left child missing");
            return left.get().findLeaf();
        }