void (CheckedTreeNode root, final List<? extends DetectedFrameworkDescription> frameworks) { Map<VirtualFile, FrameworkDirectoryNode> nodes = new HashMap<>(); List<DetectedFrameworkNode> externalNodes = new ArrayList<>(); for (DetectedFrameworkDescription framework : frameworks) { VirtualFile parent = VfsUtil.getCommonAncestor(framework.getRelatedFiles()); if (parent != null && !parent.isDirectory()) { parent = parent.getParent(); } final DetectedFrameworkNode frameworkNode = new DetectedFrameworkNode(framework, myContext); if (parent != null) { createDirectoryNodes(parent, nodes).add(frameworkNode); } else { externalNodes.add(frameworkNode); } } List<FrameworkDirectoryNode> rootDirs = new ArrayList<>(); for (FrameworkDirectoryNode directoryNode : nodes.values()) { if (directoryNode.getParent() == null) { rootDirs.add(directoryNode); } } for (FrameworkDirectoryNode dir : rootDirs) { root.add(collapseDirectoryNode(dir)); } for (DetectedFrameworkNode node : externalNodes) { root.add(node); } }