Recursively convert objects into nested hashes