let pathfindingloop cave src dst f' f'' dist =
let rec loop (visited, waiting) =
try
loop (f'' cave dst visited waiting dist)
with
| Exception_intpairhash visited -> visited
| _ -> IntPairHash.create 1
in
path src dst (loop (f' cave src dst))