private static @Nullable List<ConfigurationFromContext> doGetConfigurationsFromContext(@NotNull Location location,
                                                                                         @NotNull ConfigurationContext context,
                                                                                         boolean strict,
                                                                                         boolean preferExisting) {
    final ArrayList<ConfigurationFromContext> configurationsFromContext = new ArrayList<>();
    for (RuntimeConfigurationProducer producer : findAllProducers(location, context)) {
      configurationsFromContext.add(new ConfigurationFromContextWrapper(producer));
    }

    for (RunConfigurationProducer producer : RunConfigurationProducer.getProducers(context.getProject())) {
      ProgressManager.checkCanceled();
      ConfigurationFromContext fromContext = preferExisting
                                             ? producer.findOrCreateConfigurationFromContext(context)
                                             : producer.createConfigurationFromContext(context);
      if (fromContext != null) {
        configurationsFromContext.add(fromContext);
      }
    }

    if (configurationsFromContext.isEmpty()) return null;
    configurationsFromContext.sort(ConfigurationFromContext.COMPARATOR);

    if(strict) {
      final ConfigurationFromContext first = configurationsFromContext.get(0);
      for (Iterator<ConfigurationFromContext> it = configurationsFromContext.iterator(); it.hasNext();) {
        ConfigurationFromContext producer = it.next();
        if (producer != first && ConfigurationFromContext.COMPARATOR.compare(producer, first) > 0) {
          it.remove();
        }
      }
    }

    return configurationsFromContext;
  }
private static @Nullable List<ConfigurationFromContext> doGetConfigurationsFromContext(@NotNull Location location,
                                                                                         @NotNull ConfigurationContext context,
                                                                                         boolean strict,
                                                                                         boolean preferExisting)