# define nested_hash
nested_hash = Hash.new { |hash, key| hash[key] = Hash.new(&hash.default_proc) }
# and clone to use
n = nested_hash.clone
# storing data
n[:x][:y][:z] = :xyz
n[:x][:a] = :abc
n[:x][:y][:a] = :cdf
n[:a][:n][:a] = :cdf
n[:b][:y][:a] = :cfd
n[:b][:n][:a] = :cfd
n[:b][:n][:a] = :cfd
p nested_hash #=> {}
pp n
=begin
{:x=>{:y=>{:z=>:xyz, :a=>:cdf}, :a=>:abc},
:a=>{:n=>{:a=>:cdf}},
:b=>{:y=>{:a=>:cfd}, :n=>{:a=>:cfd}}}
=end