title: Recursion vs loops
body: <p>I'm facing a problem where both recursion and using a loop seem like natural solutions. Is there a convention or "preferred method" for cases like this? (Obviously it is not quite as simple as below)</p>
  
  <h2>Recursion</h2>
  
  <pre class="lang-js prettyprint-override"><code>Item Search(string desired, Scope scope) {
      foreach(Item item in scope.items)
          if(item.name == desired)
              return item;
  
      return scope.Parent ? Search(desired, scope.Parent) : null;
  }
  </code></pre>
  
  <h2>Loop</h2>
  
  <pre class="lang-js prettyprint-override"><code>Item Search(string desired, Scope scope) {
      for(Scope cur = scope; cur != null; cur = cur.Parent)
          foreach(Item item in cur.items)
              if(item.name == desired)
                  return item;
  
      return null;
  }
  </code></pre>