HierarchicalConfigurable (@NotNull String id, @NotNull Map<String, HierarchicalConfigurable> idToConfigurable, @NotNull Set<? super String> visited, @NotNull Map<String, List<String>> idTree) { HierarchicalConfigurable wrapper = idToConfigurable.get(id); if (visited.contains(id)) { return wrapper; } visited.add(id); List<String> childIds = idTree.get(id); if (childIds != null) { for (String childId : childIds) { HierarchicalConfigurable childWrapper = addChildrenRec(childId, idToConfigurable, visited, idTree); wrapper = wrapper.addChild(childWrapper); } idToConfigurable.put(id, wrapper); } return wrapper; }