struct
type t = T of string * t list
let leaf msg = T(msg,[])
let add_child (T(msg,childs)) x = T(msg, childs @ [x])
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
end