PsiElement () { final PyImportElement[] elements = getImportElements(); if (elements.length == 1) { final PyImportElement element = elements[0]; final QualifiedName importedQName = element.getImportedQName(); final PsiFile file = element.getContainingFile(); if (file != null) { if (importedQName != null && importedQName.getComponentCount() > 1 && PyUtil.isPackage(file)) { final QualifiedName packageQName = importedQName.removeLastComponent(); final PsiElement resolvedImport = PyUtil.turnDirIntoInit(ResolveImportUtil.resolveImportElement(element, packageQName)); if (resolvedImport == file) { return element.resolve(); } } } } return null; }