title: Checking a nested hash key
body: <p>I have a hash <code>yaml</code>, which is sometimes like:</p>
  
  <pre><code>{"foo" =&gt; {"bar" =&gt; 10}}
  </code></pre>
  
  <p>and sometimes like:</p>
  
  <pre><code>{"foo" =&gt; nil}
  </code></pre>
  
  <p>I want to do a certain action depending on whether <code>"bar"</code> is present.</p>
  
  <p>I write this code:</p>
  
  <pre><code>if yaml["foo"] &amp;&amp; yaml["foo"].key?["bar"]
  ...
  </code></pre>
  
  <p>I'd like to know if there's an idiomatic way to deal with that conditional, especially the first part where I have to check the existence of the parent key.</p>