@Override
  protected Map<OrderEntry, OrderAware> importData(final @NotNull Collection<? extends DataNode<ModuleDependencyData>> toImport,
                                                   @NotNull final Module module,
                                                   @NotNull final IdeModifiableModelsProvider modelsProvider) {
    final Map<Pair<String /* dependency module internal name */, /* dependency module scope */DependencyScope>, ModuleOrderEntry> toRemove =
      new HashMap<>();
    final Map<OrderEntry, OrderAware> orderEntryDataMap = new LinkedHashMap<>();
    final List<ModuleOrderEntry> duplicatesToRemove = new ArrayList<>();
    for (OrderEntry entry : modelsProvider.getOrderEntries(module)) {
      if (entry instanceof ModuleOrderEntry e) {
        Pair<String, DependencyScope> key = Pair.create(e.getModuleName(), e.getScope());
        if (toRemove.containsKey(key)) {
          duplicatesToRemove.add(e);
        }
        else {
          toRemove.put(key, e);
        }
      }
    }
    final Set<ModuleDependencyData> processed = new HashSet<>();
    final ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module);
    for (DataNode<ModuleDependencyData> dependencyNode : toImport) {
      final ModuleDependencyData dependencyData = dependencyNode.getData();

      if (processed.contains(dependencyData)) continue;
      processed.add(dependencyData);

      final ModuleData moduleData = dependencyData.getTarget();
      Module ideDependencyModule = modelsProvider.findIdeModule(moduleData);

      if (ideDependencyModule != null) {
        final String targetModuleName = ideDependencyModule.getName();
        toRemove.remove(Pair.create(targetModuleName, dependencyData.getScope()));
        dependencyData.setInternalName(targetModuleName);
      }

      ModuleOrderEntry orderEntry;
      if (module.equals(ideDependencyModule)) {
        // skip recursive module dependency check
        continue;
      }
      else {
        if (ideDependencyModule == null) {
          LOG.warn(String.format(
            "Can't import module dependency for '%s' module. Reason: target module (%s) is not found at the ide",
            module.getName(), dependencyData
          ));
        }
        orderEntry = modelsProvider.findIdeModuleDependency(dependencyData, module);
        if (orderEntry == null) {
          orderEntry = ReadAction.compute(() ->
            ideDependencyModule == null
            ? modifiableRootModel.addInvalidModuleEntry(moduleData.getInternalName())
            : modifiableRootModel.addModuleOrderEntry(ideDependencyModule));
        }
      }

      orderEntry.setScope(dependencyData.getScope());
      orderEntry.setExported(dependencyData.isExported());

      orderEntry.setProductionOnTestDependency(dependencyData.isProductionOnTestDependency());

      orderEntryDataMap.put(orderEntry, dependencyData);
    }

    if (!toRemove.isEmpty() || !duplicatesToRemove.isEmpty()) {
      Collection<ModuleOrderEntry> orderEntries = ContainerUtil.toCollection(concat(duplicatesToRemove, toRemove.values()));
      removeData(orderEntries, module, modelsProvider);
    }
    return orderEntryDataMap;
  }
@Override
  protected Map<OrderEntry, OrderAware> importData(final @NotNull Collection<? extends DataNode<ModuleDependencyData>> toImport,
                                                   @NotNull final Module module,
                                                   @NotNull final IdeModifiableModelsProvider modelsProvider)