Object (@Nullable Object node) { Object userObject = TreeUtil.getUserObject(node); Object element = null; if (userObject instanceof AbstractTreeNode) { AbstractTreeNode descriptor = (AbstractTreeNode)userObject; element = descriptor.getValue(); } else if (userObject instanceof NodeDescriptor) { NodeDescriptor descriptor = (NodeDescriptor)userObject; element = descriptor.getElement(); if (element instanceof AbstractTreeNode) { element = ((AbstractTreeNode<?>)element).getValue(); } } else if (userObject != null) { element = userObject; } return element; }