title: How to prevent the arrowhead anti-pattern
body: <p>I'm a bit confused about how to best refactor my code into something more readable.</p>
  
  <p>Consider this piece of code:</p>
  
  <pre><code>var foo = getfoo();
  if(foo!=null)
  {
      var bar = getbar(foo);
      if(bar!=null)
      {
          var moo = getmoo(bar);
          if(moo!=null)
          {
              var cow = getcow(moo);
              ...
          }
      }
  }
  return;
  </code></pre>
  
  <p>As you can see, lots of nested <code>if</code> blocks, needed because each nested if is dependent on the previous values.</p>
  
  <p>Now I was wondering how to make my code a bit cleaner in this regard.</p>
  
  <p>Some options I have thought of myself would be to:</p>
  
  <ul>
  <li>return after each if clause, meaning I'd have multiple places where I leave my method</li>
  <li>throw <code>ArgumentNullException</code>s, after which I'd catch them in the end and place the return statement in my finally clause (or outside the try/catch block)</li>
  <li>work with a label and <code>goto:</code></li>
  </ul>
  
  <p>Most of these options seem a bit "dirty" to me, so I was wondering if there was a good way to clean up this mess that I've created.</p>