private static void filterAndReportDuplicatingContentRoots(@NotNull MultiMap<DataNode<ModuleData>, DataNode<ContentRootData>> moduleNodeToRootNodes,
                                                             @NotNull Project project) {
    Map<String, DuplicateModuleReport> filter = new LinkedHashMap<>();

    for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> entry : moduleNodeToRootNodes.entrySet()) {
      ModuleData moduleData = entry.getKey().getData();
      Collection<DataNode<ContentRootData>> crDataNodes = entry.getValue();
      for (Iterator<DataNode<ContentRootData>> iterator = crDataNodes.iterator(); iterator.hasNext(); ) {
        DataNode<ContentRootData> crDataNode = iterator.next();
        String rootPath = crDataNode.getData().getRootPath();
        DuplicateModuleReport report = filter.putIfAbsent(rootPath, new DuplicateModuleReport(moduleData));
        if (report != null) {
          report.addDuplicate(moduleData);
          iterator.remove();
          crDataNode.clear(true);
        }
      }
    }

    Map<String, DuplicateModuleReport> toReport = filter.entrySet().stream()
      .filter(e -> e.getValue().hasDuplicates())
      .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (r1, r2) -> {
        LOG.warn("Unexpected duplicates in keys while collecting filtered reports");
        return r2;
      }, LinkedHashMap::new));

    boolean hasDuplicates = !toReport.isEmpty();
    HasSharedSourcesUtil.setHasSharedSources(project, hasDuplicates);
    if (hasDuplicates) {
      String notificationMessage = prepareMessageAndLogWarnings(toReport);
      if (notificationMessage != null) {
        showNotificationsPopup(project, toReport.size(), notificationMessage);
      }
    }
  }
private static void filterAndReportDuplicatingContentRoots(@NotNull MultiMap<DataNode<ModuleData>, DataNode<ContentRootData>> moduleNodeToRootNodes,
                                                             @NotNull Project project)