/**
 *
 * @param {TaskGroup|Task} root
 * @return {number} number of leaf tasks below supplied root
 */
export function task_tree_compute_leaf_tasks(root) {
    let result = 0;

    if (root.isTaskGroup) {

        const children = root.children;
        const n = children.length;
        for (let i = 0; i < n; i++) {
            result += task_tree_compute_leaf_tasks(children[i]);
        }
    } else {
        result += 1;
    }

    return result;
}
