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