AbstractTestProxy (JTree tree) { TreePath treePath = tree.getSelectionPath(); if (treePath != null) { final Object component = treePath.getLastPathComponent(); if (component instanceof DefaultMutableTreeNode) { final Object userObject = ((DefaultMutableTreeNode)component).getUserObject(); if (userObject instanceof NodeDescriptor) { return (AbstractTestProxy)((NodeDescriptor<?>)userObject).getElement(); } } } return null; }