PyImportedNameDefiner (PyReferenceExpression expr) { for (ResolveResult result : expr.getReference().multiResolve(false)) { final PsiElement e = result.getElement(); if (e instanceof PyImportElement) { return (PyImportElement)e; } if (e instanceof PyStarImportElement) { return (PyStarImportElement)e; } } return null; }