JSFiddle - React, Tailwind, and code Playground

HTML

<div id="start" class="group">
    <span class="child"></span>
    <div class="group">
        <span class="child"></span>
        <span class="child"></span>
        <span class="child"></span>
    </div>
    <span class="child"></span>
    <span class="child"></span>
    <span class="child"></span>
</div>

JavaScript

var current =  $('#start');

alert(current.find('.child').filter(function() {
    return $(this).closest('.group')[0] == current[0];
}).length);