code: public final void validate() {
      this.accept(new TreeVisitor() {
        @Override
        public boolean preVisit(TreeNode node) {
          node.validateInner();
          return true;
        }
      });
    }
docs: Validates the tree to preemptively catch errors.