JSFiddle - React, Tailwind, and code Playground
HTML
<div class ="container">
<div class ="level1">
<div class = "level2">
<other nested divs and html here...>
<div class = "levelN" id="idLevelN">
<div> hide me!
</div>
</div>
</other nested divs and html here...>
</div>
</div>
</div>
JavaScript
if ($( '#idLevelN' ).parents('.container').length){
$( '#idLevelN').children().hide();
}