boolean (@NotNull RunConfiguration configuration, @NotNull BiPredicate<? super RunConfiguration, ? super ExecutionTarget> action) { Set<RunConfiguration> recursionGuard = new HashSet<>(); LinkedList<Pair<RunConfiguration, ExecutionTarget>> toProcess = new LinkedList<>(); toProcess.add(Pair.create(configuration, null)); while (!toProcess.isEmpty()) { Pair<RunConfiguration, ExecutionTarget> eachWithTarget = toProcess.pollFirst(); assert eachWithTarget != null; if (!recursionGuard.add(eachWithTarget.first)) { continue; } RunConfiguration eachConfiguration = eachWithTarget.first; if (eachConfiguration instanceof CompoundRunConfiguration) { for (Map.Entry<RunConfiguration, ExecutionTarget> subConfigWithTarget : ((CompoundRunConfiguration)eachConfiguration).getConfigurationsWithTargets(getRunManager()).entrySet()) { toProcess.add(Pair.create(subConfigWithTarget.getKey(), subConfigWithTarget.getValue())); } } else if (!action.test(eachWithTarget.first, eachWithTarget.second)) { return false; } } return true; }