static List<ClickHouseNode> pickNodes(Collection<ClickHouseNode> source, ClickHouseNodeSelector selector,
            int groupSize) {
        boolean hasSelector = selector != null && selector != ClickHouseNodeSelector.EMPTY;
        final List<ClickHouseNode> list;
        if (groupSize < 1) {
            if (hasSelector) {
                list = new LinkedList<>();
                for (ClickHouseNode node : source) {
                    if (selector.match(node)) {
                        list.add(node);
                    }
                }
            } else {
                list = new ArrayList<>(source);
            }
        } else {
            list = new ArrayList<>(groupSize);
            int count = 0;
            for (ClickHouseNode node : source) {
                if (!hasSelector || selector.match(node)) {
                    list.add(node);
                    count++;
                }
                if (count >= groupSize) {
                    break;
                }
            }
        }
        return list;
    }
Picks node from {@code source} and put into {@code target}.

@param source    list of nodes to pick
@param selector  node selector for filtering out nodes
@param groupSize maximum number of nodes allowed
@return non-null selected nodes
clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseNodes.java