let find_all_rec xs map =
let visited = Hashtbl.create 32 in
let rec self x acc =
try
Hashtbl.find visited x; acc
with Not_found ->
Hashtbl.replace visited x ();
let acc = Resources.add x acc in
try Resources.fold self (SMap.find x map) acc
with Not_found -> acc
in List.fold_right self xs Resources.empty