let rec fold_assoc op acc = function | Tprim( f , ts ) when op = f -> List.fold_left (fold_assoc op) acc ts | e -> e::acc