PyFunction (List<PsiElement> superMethods, PyClass containingClass) { for (PyClass ancestor : containingClass.getAncestorClasses(null)) { for (PsiElement method : superMethods) { if (ancestor.equals(((PyFunction)method).getContainingClass())) return (PyFunction)method; } } return (PyFunction) superMethods.get(superMethods.size()-1); }