List<PsiReturnStatement> (PsiElement body) { List<PsiReturnStatement> returns = new ArrayList<>(); body.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitClass(@NotNull PsiClass psiClass) { } @Override public void visitLambdaExpression(@NotNull PsiLambdaExpression expression) { } @Override public void visitReturnStatement(@NotNull PsiReturnStatement returnStatement) { super.visitReturnStatement(returnStatement); returns.add(returnStatement); } }); return returns; }