PsiElement (DefaultMutableTreeNode node) { if (node.getUserObject() instanceof ViewerNodeDescriptor descriptor) { Object elementObject = descriptor.getElement(); return elementObject instanceof PsiElement ? (PsiElement)elementObject : elementObject instanceof ASTNode ? ((ASTNode)elementObject).getPsi() : null; } return null; }