private static Set<String> findDuplicates(List<RepositoryInfo> input, Function<RepositoryInfo, String> keyExtractor) {
    ListMultimap<String, RepositoryInfo> itemsByKey = Multimaps.index(input, keyExtractor);
    Set<String> duplicates = new HashSet<>();
    for (Map.Entry<String, Collection<RepositoryInfo>> entry: itemsByKey.asMap().entrySet()) {
      if (entry.getValue().size() > 1) {
        Set<RepositoryInfo> differingItems = new HashSet<>();
        differingItems.addAll(entry.getValue());
        if (differingItems.size() > 1) {
          duplicates.add(entry.getKey());
        }
      }
    }
    return duplicates;
  }
Finds duplicate repository infos. Duplicateness is checked on the property specified in the keyExtractor.
Items that are equal don't count as duplicate, only differing items with the same key
@param input the input list
@param keyExtractor a function to that returns the property to be checked
@return a set containing the keys of duplicates
ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java