// calculate the size of binary tree (number of nodes)
const sizeTree = (root) => {
if (!root) return 0;
let queue = [root];
let size = 0;
while (queue.length > 0) {
let current = queue.shift();
if (current.left) queue.push(current.left);
if (current.right) queue.push(current.right);
size += 1;
}
return size;
};