score:1

Accepted answer

Adding this at the end of the initial loading (after the call to update(root)) does the trick. It relies on the _children concept utilized here to store children not currently displayed.

root.each(function(d) {
    if (d.depth > 0) {
        d._children = d.children;
        d.children = null;
    }
    update(d)
});

Related Query