let topological_closure l = let add l x = if List.mem x l then l else x :: l in let l = List.fold_left begin fun acc p -> add (List.fold_left add acc p.dependencies) p end [] l in List.rev l