class Psych::Visitors::ToRuby

def revive_hash hash, o

def revive_hash hash, o
  o.children.each_slice(2) { |k,v|
    key = accept(k)
    val = accept(v)
    if key == '<<'
      case v
      when Nodes::Alias
        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
      hash[key] = val
    end
  }
  hash
end