public static <M> void buildModelsInParallel(
    @NotNull BuildController controller,
    @NotNull Collection<? extends GradleBuild> buildModels,
    @NotNull Class<M> modelClass,
    @NotNull GradleModelConsumer consumer
  ) {
    List<BuildAction<Pair<BasicGradleProject, M>>> buildActions = new ArrayList<>();
    for (GradleBuild buildModel : buildModels) {
      for (BasicGradleProject gradleProject : buildModel.getProjects()) {
        buildActions.add((BuildAction<Pair<BasicGradleProject, M>>)innerController -> {
          M model = innerController.findModel(gradleProject, modelClass);
          if (model == null) {
            return null;
          }
          return new Pair<>(gradleProject, model);
        });
      }
    }
    List<Pair<BasicGradleProject, M>> models = controller.run(buildActions);
    for (Pair<BasicGradleProject, M> model : models) {
      if (model != null) {
        consumer.consumeProjectModel(model.first, model.second, modelClass);
      }
    }
  }
public static <M> void buildModelsInParallel(
    @NotNull BuildController controller,
    @NotNull Collection<? extends GradleBuild> buildModels,
    @NotNull Class<M> modelClass,
    @NotNull GradleModelConsumer consumer
  )