List<PsiElement> (@NotNull PsiReference reference) { if (reference instanceof PsiPolyVariantReference) { final ResolveResult[] results = ((PsiPolyVariantReference)reference).multiResolve(false); final List<PsiElement> resolved = new ArrayList<>(); for (ResolveResult result : results) { final PsiElement element = result.getElement(); if (element != null) { resolved.add(element); } } for (PsiElement element : resolved) { if (element instanceof PyClass) { return Collections.singletonList(element); } } return resolved; } final PsiElement element = reference.resolve(); if (element != null) { return Collections.singletonList(element); } return Collections.emptyList(); }