You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: bson_orderedhash.rb
    path of file: ./repos/github-mirror/lib/ghtorrent
    
    the code of the file until where you have to start completion: require 'json'
require 'bson'

class BSON::OrderedHash

  # Convert a BSON result to a +Hash+
  def to_h
 
    
  def to_h
    inject({}) do |acc, element|
      k, v = element;
      acc[k] = if v.class == Array then
                 v.map{|x| if x.class == BSON::OrderedHash then x.to_h else x end}
               elsif v.class == BSON::OrderedHash then
                 v.to_h
               else
                 v
               end;
      acc
    end
  end