let path_comb node found hist =
(* add the current node to the list *)
let res =
match hist with
None -> node :: []
| Some hist -> node :: hist
in
(* when we have reached a goal, it is save to reverse the list
(no further search at this point)*)
if found then Some (List.rev res) else Some res