code: static Collection<Node> getVarsDeclaredInBranch(Node root) {
      VarCollector collector = new VarCollector();
      visitPreOrder(
          root,
          collector,
          MATCH_NOT_FUNCTION);
      return collector.vars.values();
    }
docs: Retrieves vars declared in the current node tree, excluding descent scopes.