let remove_cycles tree =
    match find_cycles tree with
      x::t -> let next_cyc = (find_next_cycle (x::t) tree)
              in remove_cycles2 (rearrange tree (List.hd (List.rev next_cyc)) next_cyc) next_cyc 20
    | _ -> Right "Graph has no cycles"