StreamEx<PsiElement> (@NotNull PyReferenceExpression referenceExpression, @NotNull Set<PyReferenceExpression> visited) { return StreamEx .of(resolveLocally(referenceExpression)) .flatMap( element -> { if (element instanceof PyTargetExpression) { final PyExpression assignedValue = ((PyTargetExpression)element).findAssignedValue(); if (assignedValue instanceof PyReferenceExpression && visited.add((PyReferenceExpression)assignedValue)) { return fullMultiResolveLocally((PyReferenceExpression)assignedValue, visited); } return StreamEx.of(assignedValue); } return StreamEx.of(element); } ); }