```
       a              
      /|\            
     b f  c           
   /  /   
  d  x
 /\
e  h

```

I have this kind of tree structure in my application. I want to traverse this tree depth first and delete the nodes depth first. Node can have multiple childs. 

I tried to do but it is deleting not in depth first order like e,h,d,b,x,f,c,a. I mean it should delete childs nodes then parent node.

```
function deleteNode(node) {
    let childs = node.getChildrens();
    if(childs === undefined || childs === null) {
        remove(node);
    } else
        for(int i = 0; i < childs.length; i++) {
            // if childs then 
            deleteNode(childs[i])
        }
    }   
    remove(node);
}   

```