PsiElement (PsiElement element) { while (element instanceof PsiCodeBlock codeBlock) { final PsiStatement[] statements = codeBlock.getStatements(); if (statements.length != 1) { break; } final PsiStatement statement = statements[0]; if (statement instanceof PsiReturnStatement) { return ((PsiReturnStatement)statement).getReturnValue(); } else if (statement instanceof PsiExpressionStatement) { return ((PsiExpressionStatement)statement).getExpression(); } else if (statement instanceof PsiBlockStatement) { element = ((PsiBlockStatement)statement).getCodeBlock(); } else { break; } } return element; }