DefaultMutableTreeNode () { // start edit last selected component if editable if (myTree.getLastSelectedPathComponent() instanceof RepositoryNode selectedNode) { if (selectedNode.isEditableNow()) return selectedNode; } List<RepositoryNode> repositoryNodes = getChildNodesByType((DefaultMutableTreeNode)myTree.getModel().getRoot(), RepositoryNode.class, false); RepositoryNode editableNode = ContainerUtil.find(repositoryNodes, repositoryNode -> repositoryNode.isEditableNow()); if (editableNode != null) { TreeUtil.selectNode(myTree, editableNode); } return editableNode; }