utility method to check if node is leaf
public virtual bool isLeaf ( Node root ) { if ( root == null ) { return false ; } if ( root . left == null && root . right == null ) { return true ; } return false ; }