let path_opt cave path foundf =
let rec loop (seen, notseen, tocheck, havechecked) =
match notseen with
| [] -> seen
| _ -> loop (path_opt'' cave
(seen, notseen, tocheck, havechecked) foundf)
in
loop (path_opt' cave path)