code: function parens(parent, child) {
    if (precedence(parent) >= precedence(child))
      return to_s(child);
    else
      return "(" + to_s(child) + ")";
  }
docs: serializes child node and wraps it inside parenthesis if the precedence rules compared to parent node would require so.