Maybe<PyCallable> (@Nullable PyExpression expr) { if (expr == null || expr instanceof PyNoneLiteralExpression) { return NONE; } if (expr instanceof PyCallable) { return new Maybe<>((PyCallable)expr); } final PsiReference ref = expr.getReference(); if (ref != null) { PsiElement something = ref.resolve(); if (something instanceof PyCallable) { return new Maybe<>((PyCallable)something); } } return NONE; }