traverses and object and swaps a key for another