refactoring recursive mapping of maps