boolean (@NotNull PsiElement element) { if (element instanceof PyReferenceExpression ref && PsiTreeUtil.getParentOfType(element, PyImportElement.class) == null) { if (myQualifierName.equals(PyPsiUtils.toPath(ref))) { // filter out other names that might resolve to our target final PsiElement parentElt = ref.getParent(); if (parentElt instanceof PyQualifiedExpression) { // really qualified by us, not just referencing? final PsiElement resolved = ref.getReference().resolve(); if (resolved == myReferee) references.add(ref.getReference()); } else { myHasModuleReference = true; } } } return true; }