let rec collect_assoc op xs = function | [] -> List.rev xs | Tapp(id,ts) :: others when id = op -> collect_assoc op (collect_assoc op xs ts) others | t::others -> collect_assoc op (t::xs) others