void (StubElement<?> stubElement) { TreeNode node = TreeUtil.treeNodeTraverser(getRoot()).traverse().find( (treeNode) -> treeNode instanceof DefaultMutableTreeNode && ((StubTreeNode)((DefaultMutableTreeNode)treeNode).getUserObject()).getStub() == stubElement ); if (node != null) { TreePath path = TreePathUtil.pathToTreeNode(node); myStubTree.getSelectionModel().setSelectionPath(path); } }