title: Rearranging levels of a nested dictionary in python
body: <p>Is there a library that would help me achieve the task to rearrange the levels of a nested dictionary </p>
  
  <p>Eg: From this:</p>
  
  <pre><code>{1:{"A":"i","B":"ii","C":"i"},2:{"B":"i","C":"ii"},3:{"A":"iii"}}
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>{"A":{1:"i",3:"iii"},"B":{1:"ii",2:"i"},"C":{1:"i",2:"ii"}}
  </code></pre>
  
  <p>ie first two levels on a 3 levelled dictionary swapped. So instead of 1 mapping to A and 3 mapping to A, we have A mapping to 1 and 3.</p>
  
  <p>The solution should be practical for an arbitrary depth and move from one level to any other within.</p>