hierarchicalData = {
const maxDepth = 3;
const numChildren = 5;
function buildTree(node, depth) {
if (depth <= maxDepth) {
node.children = Array(numChildren).fill(null)
.map(() => ({ name: String(depth) }));
node.children.forEach(child => buildTree(child, depth + 1));
} else {
node.value = 1;
}
return node;
}
return buildTree({ name: "root" }, 1);
}