code: private void initScopeRoots(Node n) {
      Deque<Node> queuedScopeRoots = new ArrayDeque<>();
      while (n != null) {
        if (isScopeRoot(n)) {
          queuedScopeRoots.addFirst(n);
        }
        n = n.getParent();
      }
      for (Node queuedScopeRoot : queuedScopeRoots) {
        pushScope(queuedScopeRoot);
      }
    }
docs: Prefills the scopeRoots stack up to a given spot in the AST. Allows for starting traversal at
  any spot while still having correct scope state.