List<PsiElement> (PsiFile file, int offset) { PsiElement elementAtCaret = PsiUtilCore.getElementAtOffset(file, offset); return PsiTreeUtil.collectParents(elementAtCaret, PyExpression.class, true, e -> e instanceof PyStatement || e instanceof PyFile); }