If the node is leaf then we just increment the no . of leaves under the subtree of a node
leaves [ a ] += 1 ; } else { for ( let i = 0 ; i < v [ a ] . length ; i ++ ) { if ( v [ a ] [ i ] . first == par ) continue ;