JSFiddle - React, Tailwind, and code Playground

HTML

<div id="start">
        <div>
            <span>Hello world</span>
            <ul class="valid-result"> ... </ul>
            <ul class="valid-result">
                <li>
                    <ul class="not-a-result"> ... </ul>
                </li>
            </ul>
            <div>
                <ul class="valid-result"> ... </ul>
            </div>
        </div>
    </div>

JavaScript

jQuery.fn.findFirst = function (sel) {
    return this.map(function() {
        return $(this).children().map(function() {
            if ($(this).is(sel)) {
                return $(this);
            } else {
                return $(this).findFirst(sel);
            }
        });
    });
} 

$el = $("#start").findFirst("ul");
alert($el.html());