@Nullable
  public static Sdk getJdkToRunModule(Module module, boolean productionOnly) {
    final Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk();
    if (moduleSdk == null) {
      return null;
    }

    final Set<Sdk> sdksFromDependencies = new LinkedHashSet<>();
    OrderEnumerator enumerator = OrderEnumerator.orderEntries(module).runtimeOnly().recursively();
    if (productionOnly) {
      enumerator = enumerator.productionOnly();
    }
    enumerator.forEachModule(module1 -> {
      Sdk sdk = ModuleRootManager.getInstance(module1).getSdk();
      if (sdk != null && sdk.getSdkType().equals(moduleSdk.getSdkType())) {
        sdksFromDependencies.add(sdk);
      }
      return true;
    });
    return sdksFromDependencies.stream().max(moduleSdk.getSdkType().versionComparator()).orElse(moduleSdk);
  }
@Nullable
  public static Sdk getJdkToRunModule(Module module, boolean productionOnly)