I can see you are making a new dict with keys that were previously values, but what this is doing is somewhat opaque. It might be useful to add a comment for what is happening here.