Support for extreme nesting with key mapping

@icanzilb I ran into a problem with extreme nesting and key mapping.
I've got a test case which is definitely good. Please let me know what you think of my solution.
TIA!