You have an "outer" ul and an "inner" ul. Selecting the inner ul is very easy, you just use a descendent-selector ul.wrap ul.wrap. In outer one is a little bit tricky, because you'll need to use a condition with a not selector: ul.wrap:not(ul.wrap ul.wrap). You're basically saying: give me all the ul.wrap that do do not have a parent that have a wrap. If you want to select the "li's" use the direct selector i.e. > li behind each selector.
I've added it to an example for you to show it works:
Html:
<ul class="wrap" tag="outer">
<li class="out"></li>
<li class="out"></li>
<li class="out">
<ul class="wrap" tag="inner">
<li class="out"></li>
<li class="out"></li>
</ul>
</li>
</ul>
JQuery:
alert($('ul.wrap:not(ul.wrap ul.wrap)').attr('tag'));
alert($('ul.wrap ul.wrap').attr('tag'));
alert($('ul.wrap:not(ul.wrap ul.wrap) > li').length);
alert($('ul.wrap ul.wrap > li').length);
Ps. I wouldn't use 'li' selector to find the outer or inner ul. You might encounter empty ul's if you fill them programatically (which will break a selector with that's dependent on li) and why should you use something you don't need?