code: final void enableTrace(final String rootName) {
      this.trace = new ParserTrace() {
          private TreeNode current = new TreeNode(rootName, getIndex());
      
          @Override public void push(String name) {
            this.current = current.addChild(name, getIndex());
          }
          @Override public void pop() {
            current.setEndIndex(getIndex());
            this.current = current.parent();
          }
          @Override public TreeNode getCurrentNode() {
            return current;
          }
          @Override public void setCurrentResult(Object result) {
            current.setResult(result);
          }
          @Override public TreeNode getLatestChild() {
            return current.latestChild;
          }
          @Override public void setLatestChild(TreeNode latest) {
            checkState(latest == null || latest.parent() == current,
                "Trying to set a child node not owned by the parent node");
            current.latestChild = latest;
          }
          @Override public void startFresh(ParseContext context) {
            context.enableTrace(rootName);
          }
          @Override public void setStateAs(ParserTrace that) {
            current = that.getCurrentNode();
          }
        };
    }
docs: Enables parse tree tracing with {@code rootName} as the name of the root node.