boolean (@NotNull PsiExpression expression) { final PsiElement parent = expression.getParent(); if (!(parent instanceof PsiReturnStatement)) { return false; } final PsiElement grandParent = parent.getParent(); if (!(grandParent instanceof PsiCodeBlock codeBlock) || !(grandParent.getParent() instanceof PsiMethod)) { return false; } return codeBlock.getStatementCount() == 1; }