PsiElement (@NotNull PsiElement context, @NotNull PyResolveContext resolveContext) { final PsiElement parent = myParent.resolve(context, resolveContext); if (parent == null) { return null; } if (parent instanceof PyFile) { return ((PyFile) parent).findTopLevelClass(myClassName); } if (resolveContext.getTypeEvalContext().maySwitchToAST(parent)) { if (parent instanceof PyClass) { for (PsiElement element : parent.getChildren()) { if (element instanceof PyClass && myClassName.equals(((PyClass)element).getName())) { return element; } } } final ClassFinder finder = new ClassFinder(myClassName); parent.acceptChildren(finder); return finder.myResult != null ? finder.myResult : parent; } return parent; }