There is a tree style structure from which I want to keep only a specific branch.
The list is like:
ul.level-1
--li
----ul.level-2
------li
------li
--li
----ul.level-2
------li
------li
------li
By giving the element I’ve selected (a second level li element), I want to remove all top level li except the one this li belongs to.
Is this possible without iterating within the tree?
If I understand you correctly, this should do what you need: