PsiElement (@NotNull PyElement element, @NotNull PyFile file) { if (element instanceof PyFile) { return file; } final ScopeOwner owner = ScopeUtil.getScopeOwner(element); final String name = element.getName(); if (owner != null && name != null) { assert owner != element; final PsiElement originalOwner = findSimilarElement(owner, file); if (originalOwner instanceof PyTypedElement) { final TypeEvalContext context = TypeEvalContext.codeInsightFallback(file.getProject()); final PyType type = context.getType((PyTypedElement)originalOwner); final PsiElement result = resolveSimilarMember(type, name, context); return result == element ? null : result; } } return null; }