List<PyCallExpression> (@NotNull PsiElement elementAt) { final PyResolveContext context = getResolveContext(elementAt); final PyReferenceExpression referenceExpr = PsiTreeUtil.getParentOfType(elementAt, PyReferenceExpression.class); if (referenceExpr != null) { final List<PyCallExpression> calls = StreamEx.of(PyUtil.multiResolveTopPriority(referenceExpr, context)) .select(PyTargetExpression.class) .filter(target -> context.getTypeEvalContext().maySwitchToAST(target)) .map(target -> target.findAssignedValue()) .select(PyCallExpression.class) .toList(); if (!calls.isEmpty()) { return calls; } } final PyAssignmentStatement assignment = PsiTreeUtil.getParentOfType(elementAt, PyAssignmentStatement.class); if (assignment != null) { final PyExpression assignedValue = assignment.getAssignedValue(); if (assignedValue instanceof PyCallExpression) { return Collections.singletonList((PyCallExpression)assignedValue); } } final PyCallExpression immediateCall = PsiTreeUtil.getParentOfType(elementAt, PyCallExpression.class, false); if (immediateCall != null) { return Collections.singletonList(immediateCall); } return Collections.emptyList(); }