docs: public static Object getTopScopeValue(Scriptable scope, Object key)
      {
          scope = ScriptableObject.getTopLevelScope(scope);
          for (;;) {
              if (scope instanceof ScriptableObject) {
                  ScriptableObject so = (ScriptableObject)scope;
                  Object value = so.getAssociatedValue(key);
                  if (value != null) {
                      return value;
                  }
              }
              scope = scope.getPrototype();
              if (scope == null) {
                  return null;
              }
          }
      }