def to_hash(obj)
      return nil unless obj
      return obj if obj.is_a?(Hash)

      hash = {}
      obj.instance_variables.each do |key|
        hash[key[1..-1].to_sym] = deeply_to_hash(obj.instance_variable_get(key))
      end
      hash
    end
def to_hash(obj)
      return nil unless obj
      return obj if obj.is_a?(Hash)

      hash = {}
      obj.instance_variables.each do |key|
        hash[key[1..-1].to_sym] = deeply_to_hash(obj.instance_variable_get(key))
      end
      hash
    end
Convert an object to a hash representation of its instance variables.
 @return [Hash] if the object is not nil, otherwise nil is returned.