Recursive function to format object keys.