private int[] countInEachGroup(Collection<NodeCandidate> candidates) {
        int[] countInGroup = new int[requested.groups()];
        for (var candidate : candidates) {
            if (candidate.allocation().get().membership().retired()) continue;
            var currentGroup = candidate.allocation().get().membership().cluster().group();
            if (currentGroup.isEmpty()) continue;
            if (currentGroup.get().index() >= requested.groups()) continue;
            countInGroup[currentGroup.get().index()]++;
        }
        return countInGroup;
    }
Prefer to unretire nodes we don't want to retire, and otherwise those with lower index
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupAssigner.java