void (@NotNull String sourceToolName, @NotNull Element sourceElement, @NotNull Element toolElement, @NotNull Map<String, Element> scopes, @NotNull Map<String, Set<String>> mentionedTools) { Element wrapElement = transformElement(sourceToolName, sourceElement, toolElement); for (Element element : sourceElement.getChildren()) { if ("scope".equals(element.getName())) { String scopeName = element.getAttributeValue("name"); if (scopeName != null) { mentionedTools.computeIfAbsent(scopeName, s -> new HashSet<>()).add(sourceToolName); copyScopeContent(sourceToolName, element, scopes.computeIfAbsent(scopeName, key -> { Element scopeElement = element.clone(); scopeElement.removeContent(); return scopeElement; })); } } else { wrapElement.addContent(element.clone()); } } }