code: public final S getGlobalScope() {
      S result = thisScope();
      while (result.getParent() != null) {
        result = result.getParent();
      }
      return result;
    }
docs: Walks up the tree to find the global scope.