title: Why does my getParentNode function return undefined?
body: <p>I write a function, named getParentNode, that use to get some specific parentNode filtered by tagName. The code is as follow. I don't understand Why the function returns "undefined". I think it should return the specific parentNode or null. orz!
  The code is also at <a href="http://jsfiddle.net/52ed6/2/" rel="nofollow">http://jsfiddle.net/52ed6/2/</a></p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;ul&gt;
              &lt;li&gt;HTML&lt;/li&gt;
              &lt;li&gt;CSS&lt;/li&gt;
              &lt;li&gt;
                  &lt;div&gt;
                      &lt;span id="reply"&gt;Reply&lt;/span&gt;
                  &lt;/div&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
  
          &lt;script&gt;
          // Get specific parentNode
          function getParentNode(obj, selector){
              if (obj.parentNode) {
                  if ( obj.parentNode.nodeName.toLowerCase() === selector ) {
                      return obj.parentNode;
                  } else {
                      getParentNode(obj.parentNode, selector);
                  }
              } else {
                  return null;
              }
          }
          var reply = document.getElementById('reply');
          // The function getParentNode() novalid
          // The next statement popup "undefined", why?
          alert(getParentNode(reply, 'li'))
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>