What if dom generates duplicated same elements? for example:
<ul id="listitem">
<li>item1</li>
</ul>
<ul id="listitem">
<li>item1</li>
</ul>
<ul id="listitem">
<li>item1</li>
</ul>
...
Then is this possible to keep one of them and delete extra two?
ID should be unique, in case if this getting rendered by external code and you don’t have control over it then your only choice is to iterate over all ul and remove ul that are duplicates.