def revive_hash hash, o
      o.children.each_slice(2) { |k,v|
        key = accept(k)
        val = accept(v)

        if key == SHOVEL && k.tag != "tag:yaml.org,2002:str"
          case v
          when Nodes::Alias, Nodes::Mapping
            begin
              hash.merge! val
            rescue TypeError
              hash[key] = val
            end
          when Nodes::Sequence
            begin
              h = {}
              val.reverse_each do |value|
                h.merge! value
              end
              hash.merge! h
            rescue TypeError
              hash[key] = val
            end
          else
            hash[key] = val
          end
        else
          # This is where we handle the translated key
          if v.is_a?(Psych::Nodes::Scalar) && !WcaI18n::PLURALIZATION_KEYS.include?(key)
            # For scalar value, the start line registered is the correct line
            # We assume that the '#original_hash: ' comment comes on the line before.
            original_hash = @original_hashes_by_line.delete(v.start_line - 1)
            val = WcaI18n::TranslatedLeaf.new(val, original_hash)
          end
          if pluralization_map?(v)
            # For mappings, the start line registered is the line of the first key/value!
            original_hash = @original_hashes_by_line.delete(v.start_line - 2)
            val = WcaI18n::TranslatedLeaf.new(val, original_hash)
          end
          hash[key] = val
        end
      }
      hash
    end
def revive_hash hash, o
      o.children.each_slice(2) { |k,v|
        key = accept(k)
        val = accept(v)

        if key == SHOVEL && k.tag != "tag:yaml.org,2002:str"
          case v
          when Nodes::Alias, Nodes::Mapping
            begin
              hash.merge! val
            rescue TypeError
              hash[key] = val
            end
          when Nodes::Sequence
            begin
              h = {}
              val.reverse_each do |value|
                h.merge! value
              end
              hash.merge! h
            rescue TypeError
              hash[key] = val
            end
          else
            hash[key] = val
          end
        else
          # This is where we handle the translated key
          if v.is_a?(Psych::Nodes::Scalar) && !WcaI18n::PLURALIZATION_KEYS.include?(key)
            # For scalar value, the start line registered is the correct line
            # We assume that the '#original_hash: ' comment comes on the line before.
            original_hash = @original_hashes_by_line.delete(v.start_line - 1)
            val = WcaI18n::TranslatedLeaf.new(val, original_hash)
          end
          if pluralization_map?(v)
            # For mappings, the start line registered is the line of the first key/value!
            original_hash = @original_hashes_by_line.delete(v.start_line - 2)
            val = WcaI18n::TranslatedLeaf.new(val, original_hash)
          end
          hash[key] = val
        end
      }
      hash
    end
Copy from the revive_hash method in https://github.com/ruby/psych/blob/e9e4567adefc52e6511df7060851bce9fe408082/lib/psych/visitors/to_ruby.rb
 Except we override the generic case with our code.