if node is a leaf node whose data is smaller than the sum we delete the leaf . An important thing to note is a non - leaf node can become leaf when its children are deleted .
if ( isLeaf ( root ) ) { if ( sum > root . data ) root = null ; } return root ; }