There is no need to call `to_hash` every time. Let's call it only when the hash doesn't respond to `each_pair`.