目录树穷举并过滤掉该路径关联最底层不符合要求的元素

1、最底层children为空数组[]的元素该路径全部过滤

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let menuListObj = {
        children:[
            // {
            //     title:"车辆管理",
            //     children:[
            //         {
            //             title:"新车采购",
            //             children:[
            //                 {
            //                     title:"商品车采购",
            //                     children:[]
            //                 },
            //                 {
            //                     title:"资产车采购",
            //                     children:[]
            //                 }
            //             ]
            //         },
            //         {
            //             title:"额度管理",
            //             children:[{
            //                 title:"额度大类",
            //                 children:[]
            //             }]

            //         }
            //     ]
            // },
            // {
            //     title:"车辆管理02",
            //     children:[
            //         {
            //             title:"新车采购021",
            //             children:[]
            //         },
            //         {
            //             title:"额度管理022",
            //             children:[{
            //                 title:"额度大类0221",
            //                 children:[
            //                     {
            //                         title:"额度管理02211",
            //                         children:[{
            //                             title:"额度大类022111",
            //                             children:[]
            //                         }]

            //                     },
            //                     {
            //                         title:"额度管理02212",
            //                         children:[{
            //                             title:"额度大类022121"
            //        
            //                         }]

            //                     }
            //                 ]
            //             }]

            //         }
            //     ]
            // },
            {
                title:"车辆管理03"
            }
        ],
        title:'目录'
    }


    function cleanEmptyMenu(supreMenuObj,menuListObj,index){
       
        if(menuListObj.children&&menuListObj.children.length>0){
            
            menuListObj.index=0;

            for(menuListObj.index;menuListObj.index<menuListObj.children.length;){
            //    console.log(999,supreMenuObj,menuListObj);
               cleanEmptyMenu(menuListObj,menuListObj.children[menuListObj.index],menuListObj.index);
               menuListObj.index++

            }
        }

        
        if(menuListObj.children&&menuListObj.children.length==0){
            supreMenuObj.children.splice(index,1);
            supreMenuObj.index--
        }
    }



    cleanEmptyMenu(menuListObj,menuListObj,-1);
    console.log('-------',menuListObj)
  </script>
</body>
</html>