countFullNodes<T> function

int countFullNodes<T>(
  1. BinaryTreeNode<T>? root
)

Implementation

int countFullNodes<T>(BinaryTreeNode<T>? root) {
  if (root == null) return 0;
  int count = 0;
  if (root.left != null && root.right != null) count = 1;
  return count + countFullNodes(root.left) + countFullNodes(root.right);
}