When clicking a node, the Spacetree visualization unselects all tree nodes and then selects the nodes in between the root node and the selected node. This can be implemented as a recursive function, since we have to iterate through the clicked node and its ancestors to set those nodes as selected.
I defined an anonymous recursive function that receives a node and a special value as formal parameters, and sets the selected property from this node and its ancestors to the specified value:
and running it in your Firefox console.
Unfortunately, our anonymous recursive function needs to be called more than once, since we first need to unselect previous selected nodes, and then to select the nodes in between the clicked node and the root node.
Similar to the "return this" trick to chain method calls, we can add "return arguments.callee" to chain function calls.
This way, we can call our function multiple times. I'll first pass the previous clicked node in order to unselect the previous selected path, and then I'll pass the new clicked node in order to select our new path: