title: Python: Replace keys in a nested dictionary
body: <p>I have a nested dictionary <code>{1: {2: {3: None}}}</code> and a dictionary that maps keys of the nested dictionary to a set of values such as <code>{1: x, 2: y, 3: z}</code>. I want to transform the nested dictionary to this form <code>{x: {y: {z: None}}}</code>. I have tried a couple of recursive functions but I keep going in circles and confusing myself. What is the best way to achieve this?</p>
  
  <p>Edit: I forgot to mention that the level of nesting is arbitrary. The above is a simple example.</p>