presto-main/src/main/java/io/prestosql/execution/scheduler/NodeScheduler.java/NodeScheduler/selectNodes
class NodeScheduler:    public static List<InternalNode> selectNodes(int limit, Iterator<InternalNode> candidates)
    {
        checkArgument(limit > 0, "limit must be at least 1");

        List<InternalNode> selected = new ArrayList<>(limit);
        while (selected.size() < limit && candidates.hasNext()) {
            selected.add(candidates.next());
        }

        return selected;
    }