boolean (@NotNull Usage usage, @NotNull UsageTarget @NotNull [] targets) { if (usage instanceof PsiElementUsage) { final PsiElement psiElement = ((PsiElementUsage)usage).getElement(); final PsiFile containingFile = psiElement.getContainingFile(); if (containingFile instanceof PyFile) { // check whether the element is in the import list final PyImportStatementBase importStatement = PsiTreeUtil.getParentOfType(psiElement, PyImportStatementBase.class, true); return importStatement == null; } } return true; }