def __convert_value(value)
      case
      # Converts Hash to Bag instance
      when value.kind_of?(Hash)
        Bag.new(value, @__config)

      # Converts Array elements to Bag instances if needed
      when value.kind_of?(Array)
        value.map(&self.method(:__convert_value))

      # Keeps as-is other elements
      else
        value
      end
    end
def __convert_value(value)
      case
      # Converts Hash to Bag instance
      when value.kind_of?(Hash)
        Bag.new(value, @__config)

      # Converts Array elements to Bag instances if needed
      when value.kind_of?(Array)
        value.map(&self.method(:__convert_value))

      # Keeps as-is other elements
      else
        value
      end
    end
This function change value convertible to Bag into actual Bag.
 This trick enable deeply using all Bag functionalities and also
 ensures at the same time a deeply preventive copy since a new
 instance is created for this nested structure.

 In addition, it also transforms array elements of type Hash into
 Bag instance also. This enable indifferent access inside arrays
 also.

 @param value The value to convert to bag if necessary
 @return The converted value