def value_or_descend(data_hash, key, auto_vivifiy=false)
if auto_vivifiy
hash_to_vivifiy = auto_vivifiy(data_hash, key)
data_hash[key] = hash_to_vivifiy[key]
else
return nil if data_hash == nil
return nil unless data_hash.has_key?(key)
end
if data_hash[key].respond_to?(:has_key?)
cna = Chef::Node::Attribute.new(@normal, @default, @override, @automatic, @current_nesting_level)
cna.current_normal = current_normal.nil? ? Mash.new : current_normal[key]
cna.current_default = current_default.nil? ? Mash.new : current_default[key]
cna.current_override = current_override.nil? ? Mash.new : current_override[key]
cna.current_automatic = current_automatic.nil? ? Mash.new : current_automatic[key]
cna.auto_vivifiy_on_read = auto_vivifiy_on_read
cna.set_unless_value_present = set_unless_value_present
cna.set_type = set_type
cna
else
data_hash[key]
end
end