filter Deep tree of JSON removing the parent node

I'm currently trying to filter recursively the below object in Javascript, with a goal of removing an entire object from the tree when its deep child is an empty array.. below is the JSON:

{
    "name": "PARENT",
    "attributes": {
        "layer": 1,
        "category": true
    },
    "children": [
        {
            "name": "Digital Media",
            "attributes": {
                "layer": 2,
                "category": true
            },
            "children": [
                {
                    "name": "Video",
                    "attributes": {
                        "layer": 3,
                        "category": true
                    },
                    "children": [
                        {
                            "name": "Youtubes",
                            "attributes": {
                                "category": false,
                                "toolID": "124657"
                            }
                        }
                    ]
                },
                {
                    "name": "Video2",
                    "attributes": {
                        "layer": 3,
                        "category": true
                    },
                    "children": [
                        
                    ]
                }
            ]
        }
    ]
}

Using DeepDash:

const filtrate = _.filterDeep(res, (v, key, parent) => {
    if (v.hasOwnProperty("children")) {
      if (v.children.length === 0) {
        return false;
      }
      return true;
    }
    return true;
  });

However, this seems to only remove the actual key of 'children' from that part of the object. How would I go about removing it's parent object entirely? The end goal should look like this. The JSON is complex and I haven't shared it all, but ultimately if the children key is empty in any instance, I want to remove its parent node.

{
    "name": "PARENT",
    "attributes": {
        "layer": 1,
        "category": true
    },
    "children": [
        {
            "name": "Digital Media",
            "attributes": {
                "layer": 2,
                "category": true
            },
            "children": [
                {
                    "name": "Video",
                    "attributes": {
                        "layer": 3,
                        "category": true
                    },
                    "children": [
                        {
                            "name": "Youtubes",
                            "attributes": {
                                "category": false,
                                "toolID": "124657"
                            }
                        }
                    ]
                }
            ]
        }
    ]
}
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum