title: Get maximum depth of selected node in DOM using jQuery
body: <p>I would like to count count maximum 'depth' of the DOM tree structure (the length of the longest branch of a tree given its root). For example:</p>
  
  <pre><code>&lt;div class="group level0" id="group1"&gt;
      &lt;div class="group level1" id="group2"&gt;
          &lt;div class="group level2" id="group3"&gt;
              &lt;div class="group level3"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="group level1"&gt;
          &lt;div class="group level2"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>For example result for <code>div#group1</code> would be 3. Result for <code>div#group2</code> would be 2 and result for <code>div#group3</code> would be 1.</p>