Object (final TreePath selectionPath) { if (selectionPath == null) { return null; } final DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode)selectionPath.getLastPathComponent(); if (lastPathComponent == null) { return null; } final Object userObject = lastPathComponent.getUserObject(); if (!(userObject instanceof NodeDescriptor)) { return null; } final Object element = ((NodeDescriptor<?>)userObject).getElement(); if (!(element instanceof LibraryTableTreeContentElement)) { return null; } return element; }