Support nested hashes in serialize function