boolean (@NotNull PsiElement element1, @NotNull PsiElement element2) { final PyClass firstScopeOwner = PsiTreeUtil.getParentOfType(element1, PyClass.class, false, ScopeOwner.class); final PyClass secondScopeOwner = PsiTreeUtil.getParentOfType(element2, PyClass.class, false, ScopeOwner.class); return firstScopeOwner != null && firstScopeOwner == secondScopeOwner; }