void (@NotNull final MavenDomProjectModel projectDom, @NotNull final Processor<? super MavenDomProjectModel> processor) { Set<MavenDomProjectModel> processed = new HashSet<>(); Project project = projectDom.getManager().getProject(); MavenDomProjectModel parent = findParent(projectDom, project); while (parent != null) { if (processed.contains(parent)) break; processed.add(parent); if (processor.process(parent)) break; parent = findParent(parent, project); } }