Set<GradleBuild> (@NotNull BuildController controller, @NotNull GradleBuild build) { BuildEnvironment environment = controller.getModel(BuildEnvironment.class); if (environment == null) { return Collections.emptySet(); } GradleVersion gradleVersion = GradleVersion.version(environment.getGradle().getGradleVersion()); if (gradleVersion.compareTo(GradleVersion.version("3.1")) < 0) { return Collections.emptySet(); } Set<String> processedBuildsPaths = new HashSet<>(); Set<GradleBuild> nestedBuilds = new LinkedHashSet<>(); String rootBuildPath = build.getBuildIdentifier().getRootDir().getPath(); processedBuildsPaths.add(rootBuildPath); Queue<GradleBuild> queue = new ArrayDeque<>(getEditableBuilds(build, gradleVersion)); while (!queue.isEmpty()) { GradleBuild includedBuild = queue.remove(); String includedBuildPath = includedBuild.getBuildIdentifier().getRootDir().getPath(); if (processedBuildsPaths.add(includedBuildPath)) { nestedBuilds.add(includedBuild); queue.addAll(getEditableBuilds(includedBuild, gradleVersion)); } } return nestedBuilds; }