A utility function to check if a given node is leaf or not
function isLeaf ( node ) { if ( node == null ) return false ; if ( node . left == null && node . right == null ) return true ; return false ; }