@NotNull
  private static <T extends ModuleRootModel> Graph<T> createGraphGenerator(@NotNull Map<Module, T> models) {
    return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<>() {
      @NotNull
      @Override
      public Collection<T> getNodes() {
        return models.values();
      }

      @NotNull
      @Override
      public Iterator<T> getIn(final ModuleRootModel model) {
        final List<T> dependencies = new ArrayList<>();
        model.orderEntries().compileOnly().forEachModule(module -> {
          T depModel = models.get(module);
          if (depModel != null) {
            dependencies.add(depModel);
          }
          return true;
        });
        return dependencies.iterator();
      }
    }));
  }
@NotNull
  private static <T extends ModuleRootModel> Graph<T> createGraphGenerator(@NotNull Map<Module, T> models)