def extract_value(data, *keys)
      if keys.empty?
        data
      elsif data.respond_to?(:[]) && data[keys.first]
        extract_value(data[keys.first], *keys.slice(1,100))
      else
        nil
      end
    end
def extract_value(data, *keys)
      if keys.empty?
        data
      elsif data.respond_to?(:[]) && data[keys.first]
        extract_value(data[keys.first], *keys.slice(1,100))
      else
        nil
      end
    end
This method is opaque, but it was the best I could come up with using just
 the standard library. Sorry.

 Use this to safely extract values from nested hashes:

     data = {a: {b: {c: 1}}}
     extract_value(data, :a, :b, :c)
     => 1

     extract_value(data, :a, :b, :d)
     => nil

     extract_value(data, :d)
     => nil