You could just create (if nested, recursive) a function by scrolling through all the elements and check if it matters, if not, delete this property.
In your example object, a problem arises that the children property is far from empty - it is a property with the value of an array containing one empty object. Depending on your scenario, you will have to run your object multiple times, deleting empty entries step by step (maybe some optimization can be done).
As a final note, you can use for ... in to scroll through the properties of an object and for ... of to view the values ββof the object / array.
source share