Accepted answer

The v4 changelog tells us that

When used in conjunction with nest.rollup, nest.entries now returns {key, value} objects for the leaf entries, instead of {key, values}.

It is this little renaming from values to value within the leaf nodes which eventually breaks the code. Changing the helper function accordingly should get you back on track:

// Recursively sum up children's values
function sumChildren(node) {
  if (node.value) {
    node.values = node.value;   // Ensure, leaf nodes will also have a values array
    delete node.value;          // ...instead of a single value
  node.Population = node.values.reduce(function(r, v) {
    return r + (v.value? sumChildren(v) : v.Population);
  return node.Population;

Related Query