JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ul>
<li>Item 1
<ul>
<li>Item 1-1
<ul>
<li>Item 1-1-1</li>
</ul>
</li>
</ul>
</li>
</ul>
CSS
:not(li) ul:not(:has(ul)) {
background-color: tomato;
}