private static <T, R> List<R> executeInParallel(@NotNull Collection<T> collection,
                                                  @NotNull Function<T, R> method) {
    Set<RuntimeException> runtimeExceptions = ConcurrentHashMap.newKeySet();

    List<R> result = collection.parallelStream().map(item -> {
        try {
          return new Pair<>(true, method.apply(item));
        }
        catch (RuntimeException ex) {
          runtimeExceptions.add(ex);
        }
        return new Pair<Boolean, R>(false, null);
      })
      .filter(pair -> pair.getFirst())
      .map(pair -> pair.second)
      .collect(Collectors.toList());

    if (!runtimeExceptions.isEmpty()) {
      throw runtimeExceptions.stream().reduce((ex1, ex2) -> {
        ex1.addSuppressed(ex2);
        return ex1;
      }).get();
    }

    return result;
  }
private static <T, R> List<R> executeInParallel(@NotNull Collection<T> collection,
                                                  @NotNull Function<T, R> method)