boolean (@NotNull PsiCodeBlock body, @NotNull PsiReturnStatement returnStatement) { PsiElement parent = returnStatement.getParent(); while (parent != body) { if (parent instanceof PsiLoopStatement || parent instanceof PsiSwitchStatement) { return true; } parent = parent.getParent(); } return false; }