void (@NotNull MultiMap<PostfixTemplateProvider, PostfixTemplate> providerToTemplates) { myRoot.removeAllChildren(); Map<String, Set<PostfixTemplateCheckedTreeNode>> languageToNodes = new HashMap<>(); for (Map.Entry<PostfixTemplateProvider, Collection<PostfixTemplate>> entry : providerToTemplates.entrySet()) { PostfixTemplateProvider provider = entry.getKey(); String languageId = getProvidersToLanguages().get(provider); Set<PostfixTemplateCheckedTreeNode> nodes = languageToNodes.computeIfAbsent(languageId, myNodesComparator); for (PostfixTemplate template : entry.getValue()) { nodes.add(new PostfixTemplateCheckedTreeNode(template, provider, false)); } } for (Map.Entry<String, Set<PostfixTemplateCheckedTreeNode>> entry : languageToNodes.entrySet()) { DefaultMutableTreeNode languageNode = findOrCreateLanguageNode(entry.getKey()); for (PostfixTemplateCheckedTreeNode node : entry.getValue()) { languageNode.add(new PostfixTemplateCheckedTreeNode(node.getTemplate(), node.getTemplateProvider(), false)); } } myModel.nodeStructureChanged(myRoot); TreeUtil.expandAll(this); }