countLeafNodes<T> function
Implementation
int countLeafNodes<T>(BinaryTreeNode<T>? root) {
if (root == null) return 0;
if (root.left == null && root.right == null) return 1;
return countLeafNodes(root.left) + countLeafNodes(root.right);
}