PyTargetExpression (@NotNull final PyFile file, @NotNull final String name) { PyTargetExpression attr = file.findTopLevelAttribute(name); if (attr == null) { for (PyFromImportStatement element : file.getFromImports()) { PyReferenceExpression expression = element.getImportSource(); if (expression == null) continue; final PsiElement resolved = expression.getReference().resolve(); if (resolved instanceof PyFile && resolved != file) { return ((PyFile)resolved).findTopLevelAttribute(name); } } } return attr; }