title: Converting a for each loop to Coffeescript
body: <p>Trying to convert the following function to Coffeescript:</p>
  
  <pre><code>    var parse = function (elem) {
          for each(var subelem in elem) {
              if (subelem.name() !== null ) {
                  console.log(subelem.name());
                  if (subelem.children().length() &gt; 0) {
                      parse(subelem);
                  }
              } else {
                  console.log(subelem);
              }
          }
      };
     var xml = new XML(content);
     parse(xml);
  </code></pre>
  
  <p>It merely prints the element tags and any text to the console.</p>
  
  <p>Tried using:</p>
  
  <pre><code>    parse = (elem) -&gt;
          if elem.name()?                 
              console.log elem.name()
              if elem.children().length() &gt; 0
                  parse subelem for own elkey, subelem of elem
          else
              console.log elem
  
  xml = new XML content
  parse subelem for own elkey, subelem of xml
  </code></pre>
  
  <p>But it never seems to parse anything under the root xml node and ends up in an infinite recursion loop continuously printing out the root nodes tag until it blows up. Any ideas as to what I am doing wrong? Thanks.</p>