T (DomFileElement<T> element) { final DomManager domManager = element.getManager(); XmlFile xmlFile = element.getFile(); Set<XmlFile> files = new HashSet<>(); files.add(xmlFile); final XmlFile originalFile = (XmlFile)xmlFile.getOriginalFile(); if (originalFile != xmlFile) { final DomFileElement originalElement = domManager.getFileElement(originalFile); if (originalElement != null) { element = originalElement; } } files.addAll(getFilesToMerge(element)); ArrayList<T> roots = new ArrayList<>(files.size()); for (XmlFile file: files) { final DomFileElement<T> fileElement = domManager.getFileElement(file); if (fileElement != null) { roots.add(fileElement.getRootElement()); } } if (roots.size() == 1) { return roots.iterator().next(); } if (myMerger == null) { myMerger = DomService.getInstance().createModelMerger(); } return myMerger.mergeModels(getRootElementClass(), roots); }