private static SupportedFeatureKeyCollection maybeFilterSupportedFeatureKeys(
        Features<SupportedVersionRange> latestSupportedFeatures,
        boolean alterV0
    ) {
        SupportedFeatureKeyCollection converted = new SupportedFeatureKeyCollection();
        for (Map.Entry<String, SupportedVersionRange> feature : latestSupportedFeatures.features().entrySet()) {
            final SupportedVersionRange versionRange = feature.getValue();
            final SupportedFeatureKey key = new SupportedFeatureKey();
            key.setName(feature.getKey());
            if (alterV0 && versionRange.min() == 0) {
                // Some older clients will have deserialization problems if a feature's
                // minimum supported level is 0. Therefore, when preparing ApiVersionResponse
                // at versions less than 4, we must set the minimum version for these features
                // to 1 rather than 0. See KAFKA-17011 for details.
                key.setMinVersion((short) 1);
            } else {
                key.setMinVersion(versionRange.min());
            }
            key.setMaxVersion(versionRange.max());
            converted.add(key);
        }

        return converted;
    }
Find the common range of supported API versions between the locally
known range and that of another set.

@param listenerType the listener type which constrains the set of exposed APIs
@param minRecordVersion min inter broker magic
@param activeControllerApiVersions controller ApiVersions
@param enableUnstableLastVersion whether unstable versions should be advertised or not
@param clientTelemetryEnabled whether client telemetry is enabled or not
@return commonly agreed ApiVersion collection
clients/src/main/java/org/apache/kafka/common/requests/ApiVersionsResponse.java