trim_levels_to_map function

Trim levels to map