List<PsiTryStatement> (@NotNull PsiElement element) { PsiElement current = element; PsiElement parent = element.getParent(); List<PsiTryStatement> parents = new SmartList<>(); while (parent != null) { if (parent instanceof PsiLambdaExpression || parent instanceof PsiMember || parent instanceof PsiFile) break; if (parent instanceof PsiTryStatement tryStatement) { if (tryStatement.getFinallyBlock() != current && !(current instanceof PsiCatchSection)) { parents.add((PsiTryStatement)parent); } } current = parent; parent = parent.getParent(); } return parents; }