private static void collectIncludedArtifacts(JpsArtifact artifact,
                                               final Set<? super JpsArtifact> processed,
                                               final Set<? super JpsArtifact> result,
                                               final boolean withOutputPathOnly) {
    if (!processed.add(artifact)) {
      return;
    }
    if (!withOutputPathOnly || !StringUtil.isEmpty(artifact.getOutputPath())) {
      result.add(artifact);
    }

    processIncludedArtifacts(artifact, included -> collectIncludedArtifacts(included, processed, result, withOutputPathOnly));
  }
private static void collectIncludedArtifacts(JpsArtifact artifact,
                                               final Set<? super JpsArtifact> processed,
                                               final Set<? super JpsArtifact> result,
                                               final boolean withOutputPathOnly)