If parent element contains certain child element

If parent element contains certain child element

Hi.
I'm trying to hide sertain elements <button class="sidebar__categories-toggle">></button> only in those divs that do not have child elements <ul class="sidebar__categories-list"> .

So if category has subcategories then I need this sign <button class="sidebar__categories-toggle">></button>, but if not - then I need to hide it


Tried
  1. (function(jQuery) {
  2.     jQuery(document).ready(function() {
  3.         if (jQuery('li.sidebar__categories-item').find('ul.sidebar__categories-list').length !== 0) {
                jQuery('button.sidebar__categories-toggle').hide();
            }
        });
  4. })(jQuery);

But it hides all of <button class="sidebar__categories-toggle">></button> 

What am I doing wrong?
Thanks.