let add_node acc ~left ~right ~start ~stop =
  match acc with
    [] -> 
      let t =
        { t_pos_left = left;
          t_pos_right = right;
          t_type_info = Some (start, stop) ;
          t_children = [] ;
        }
      in
      [ t ]
  | l ->
      let rec find_children acc = function
        [] -> (List.rev acc, [])
      | h :: q ->
          if h.t_pos_right < left then
            (* no more children *)
            (List.rev acc, h ::q)
          else
            find_children (h::acc) q
      in
      let (children, others) = find_children [] l in
      let t =
        { t_pos_left = left ;
          t_pos_right = right ;
          t_type_info = Some (start, stop) ;
          t_children = children ;
        }
      in
      t :: others