On a tree layout using d3.js (example), I'd like to collapse nodes that are not in the branch that has been clicked on.
For example, in the above demo, try the following:
Now you should see both the children of "Child 1" and "Child 2".
I would like to have the following happen:
So children of nodes other than on the "active" branch should be hidden.
How can I best approach this? (efficiently of course, as I'll be using a fairly large dataset)