JSFiddle - React, Tailwind, and code Playground

HTML

<div id="menu">
<ul>
    <li id="0" rel="1" class="reference jstree-open jstree-undetermined">
        <ins class="jstree-icon">&nbsp;</ins>
        <a href="#" class="jstree-clicked"><ins class="jstree-checkbox">&nbsp;</ins><ins class="jstree-icon">&nbsp;</ins>Справка</a>
        <ul>
            <li id="38" rel="3" data-bin="0" class="jstree-open jstree-unchecked">
                <ins class="jstree-icon">&nbsp;</ins>
                <a href="#" class=""><ins class="jstree-checkbox">&nbsp;</ins><ins class="jstree-icon">&nbsp;</ins>New node</a>
                <ul>
                    <li id="61" rel="3" data-bin="0" class="jstree-leaf jstree-unchecked">
                        <ins class="jstree-icon">&nbsp;</ins>
                        <a href="#"><ins class="jstree-checkbox">&nbsp;</ins><ins class="jstree-icon">&nbsp;</ins>New node</a>
                    </li>
                    <li id="63" rel="3" data-bin="0" class="jstree-last jstree-leaf jstree-unchecked">
                        <ins class="jstree-icon">&nbsp;</ins>
                        <a href="#" class=""><ins class="jstree-checkbox">&nbsp;</ins><ins class="jstree-icon">&nbsp;</ins>New node</a>
                    </li>
                </ul>
            </li>
            <li id="62" rel="3" data-bin="0" class="jstree-leaf jstree-unchecked">
                <ins class="jstree-icon">&nbsp;</ins>
                <a href="#" class=""><ins class="jstree-checkbox">&nbsp;</ins><ins class="jstree-icon">&nbsp;</ins>New node</a>
            </li>
            <li id="68" rel="3" data-bin="0" class="jstree-open jstree-checked">
                <ins class="jstree-icon">&nbsp;</ins>
                <a href="#" class=""><ins class="jstree-checkbox">&nbsp;</ins><ins class="jstree-icon">&nbsp;</ins>раз</a>
                <ul>
                    <li id="71" rel="3" data-bin="0" class="jstree-last jstree-leaf jstree-checked">
                        <ins class="jstree-icon">&nbsp;</ins>
                        <a...

CSS

ul{padding-left:1em;}
#menu{display:none;}

JavaScript

function _recursion(id) {
    var list = [];
    var is_exist = false;
    $("#" + id + ">ul>li").filter(".jstree-undetermined,.jstree-checked").each(function(index, element) {
        is_exist = true;
        childs = _recursion($(element).attr('id'));
        if (childs == false) list.push({
            "id": $(element).attr('id')
        });
        else list.push({
            "id": $(element).attr('id'),
            "children": childs
        });
    });

    if (is_exist == false) return false;
    return list;
}

document.write(JSON.stringify((_recursion('menu')[0])));