I have a HTML structure that contains nested divs with the container class:
<div class="container" id="0">
<div id="1">
<div class="container" id="2">
<div class="container" id="3"></div>
</div>
<div id="4">
<div class="container" id="5"></div>
</div>
</div>
</div>
This could include more divs and deeper/different nesting.
Starting from some point in the tree I'd like to find all containers in that subtree that are not nested within other containers. So for example from div #1 I'd like to find the divs #2 and #5, but not #3 (since it is nested in container #2 already found).
What would be the best way to accomplish this?