class Lutaml::Model::KeyValueTransform

def extract_hash_for_child_mapping(child_mappings, child_obj, rules)

def extract_hash_for_child_mapping(child_mappings, child_obj, rules)
  key = nil
  value = {}
  child_mappings.each do |attr_name, path|
    rule = rules.find_by_to(attr_name)
    attr_value = normalize_attribute_value(child_obj.send(attr_name))
    next unless rule&.render?(attr_value, nil)
    next key = attr_value if path == :key
    value = extract_hash_value_for_child_mapping(path, attr_value, value)
  end
  value = nil if value.empty?
  { key => value }
end