@Nullable
  public static ScopeOwner getDeclarationScopeOwner(@Nullable PsiElement anchor, @Nullable String name) {
    if (name != null) {
      final ScopeOwner originalScopeOwner = getScopeOwner(anchor);
      ScopeOwner scopeOwner = originalScopeOwner;
      while (scopeOwner != null) {
        if (!(scopeOwner instanceof PyClass) || scopeOwner == originalScopeOwner) {
          Scope scope = ControlFlowCache.getScope(scopeOwner);
          if (scope.containsDeclaration(name)) {
            return scopeOwner;
          }
        }
        scopeOwner = getScopeOwner(scopeOwner);
      }
    }
    return null;
  }
@Nullable
  public static ScopeOwner getDeclarationScopeOwner(@Nullable PsiElement anchor, @Nullable String name)