private void maybeAssign(List<TopicPartition> unassignedPartitions, RackInfo rackInfo, boolean removeAssigned) {
            // assign all unassigned partitions
            for (Iterator<TopicPartition> iter = unassignedPartitions.iterator(); iter.hasNext();) {
                TopicPartition partition = iter.next();
                // skip if there is no potential consumer for the topic
                if (topic2AllPotentialConsumers.get(partition.topic()).isEmpty())
                    continue;

                if (maybeAssignPartition(partition, rackInfo) && removeAssigned)
                    iter.remove();
            }
        }
attempt to assign all unassigned partitions

@param unassignedPartitions partitions that are still unassigned
@param rackInfo             rack information used to match racks. If null, no rack-matching is performed
@param removeAssigned       flag that indicates if assigned partitions should be removed from `unassignedPartitions`
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java