void (final DClassElement classElement, final DItemElement itemElement, final ToolWindow window) { final ListTreeTableModelOnColumns myTreeTableModel = DynamicToolWindowWrapper.getInstance(myProject).getTreeTableModel(); window.activate(() -> { final Object rootObject = myTreeTableModel.getRoot(); if (!(rootObject instanceof DefaultMutableTreeNode rootNode)) return; DefaultMutableTreeNode node = new DefaultMutableTreeNode(itemElement); if (rootNode.getChildCount() > 0) { for (DefaultMutableTreeNode classNode = (DefaultMutableTreeNode) rootNode.getFirstChild(); classNode != null; classNode = (DefaultMutableTreeNode) rootNode.getChildAfter(classNode)) { final Object classRow = classNode.getUserObject(); if (!(classRow instanceof DClassElement otherClassName)) return; if (otherClassName.equals(classElement)) { int index = getIndexToInsert(classNode, itemElement); classNode.insert(node, index); myTreeTableModel.nodesWereInserted(classNode, new int[]{index}); DynamicToolWindowWrapper.getInstance(myProject).setSelectedNode(node); return; } } } // if there is no such class in tree int index = getIndexToInsert(rootNode, classElement); DefaultMutableTreeNode classNode = new DefaultMutableTreeNode(classElement); rootNode.insert(classNode, index); myTreeTableModel.nodesWereInserted(rootNode, new int[]{index}); classNode.add(node); myTreeTableModel.nodesWereInserted(classNode, new int[]{0}); DynamicToolWindowWrapper.getInstance(myProject).setSelectedNode(node); }, true); }