let to_string t =
let rec loop depth (T(msg,sub_msgs)) =
let pre = String.make (2*depth) ' ' in
let msg = pre ^ msg in
if List.length sub_msgs = 0
then msg
else msg ^ "\n" ^ (String.concat ~sep:"\n" (List.map ~f:(loop (depth+1)) sub_msgs))
in loop 0 t