Collection<ModuleGroup> (@NotNull ModuleGrouper grouper) { Set<ModuleGroup> result = new HashSet<>(); Set<List<String>> moduleAsGroupsPaths = ContainerUtil.map2Set(grouper.getAllModules(), module -> grouper.getModuleAsGroupPath(module)); for (Module module : grouper.getAllModules()) { List<String> group = grouper.getGroupPath(module); if (isChild(myGroupPath, group)) { final List<String> directChild = ContainerUtil.append(myGroupPath, group.get(myGroupPath.size())); if (!moduleAsGroupsPaths.contains(directChild)) { result.add(new ModuleGroup(directChild)); } } } return result; }