Fix HWIA#to_hash behavior with array of hashes.

We merged #10266, but if we use HWIA#to_hash with array of hases, the problem still exists.

/cc @vipulnsward @rafaelfranca