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:
<div class="group level0" id="group1">
<div class="group level1" id="group2">
<div class="group level2" id="group3">
<div class="group level3">
</div>
</div>
</div>
<div class="group level1">
<div class="group level2">
</div>
</div>
</div>
For example result for div#group1
would be 3. Result for div#group2
would be 2 and result for div#group3
would be 1.