docs: def tree_to_str(root):
      """
      Returns a string representation of a decision tree with
      root node `root`.
      """
  
      xs = []
      for value, node, depth in iter_tree(root):
          template = "{indent}"
          if node is not root:
              template += "case={value}\t"
          if node.attribute is None:
              template += "result={result} -- P={prob:.2}"
          else:
              template += "split by {split}:\t" +\
                          "(partial result={result} -- P={prob:.2})"
          line = template.format(indent="    " * depth,
                                 value=value,
                                 result=node.result[0],
                                 prob=node.result[1],
                                 split=str(node.attribute))
          xs.append(line)
      return "\n".join(xs)