let rss_items_of_tdl tdl =
  let rec gather_items acc groups = function
    [] -> acc
  | i :: q ->
      match rss_item_of_tdl_item i with
        None -> gather_items acc groups q
      | Some i -> gather_items ((groups, i) :: acc) groups q
  in
  let rec gather_groups groups acc = function
    [] -> acc
  | g :: q ->
      let new_groups = groups @ [g.group_title] in
      let new_acc = gather_items acc new_groups g.group_items in
      let new_acc = gather_groups new_groups new_acc g.group_groups in
      gather_groups groups new_acc q
  in
  (gather_items [] [] tdl.group_items) @
  (gather_groups [] [] tdl.group_groups)