The answer from m59 is correct -- you should use a deep copy of the "tree-data" if you need 2 trees. The tree-data that you supply is not just the definition of the tree -- it will also be used to track it's state -- the tree adds an "expanded" attribute and a "selected" attribute to each branch. So, if you share tree data, then "expanded" states are also shared. If you want 2 trees with separate state, then you need separate tree-data.
A better approach might be to keep the "tree-data" separate from your original data, whatever it is. Use a function that loops over your original data, and creates the "tree-data" from it.
If you want to have 2 trees represent a common, shared set of data, then you could use the "branch.data" attributes of the branches to refer back to elements of your original data. That is, have separate "tree data" for each tree, but have branches in both trees point to some shared data.
Suppose, for example that you have a list of "People", and you want to create 2 trees that both represent that same list of people.
First, write a function that loops over your list of people, and produces a new list of tree branches ( the "tree data" ). For each branch, set the "branch.data" to point to the original "person" object from your list of people.
Now, run your function twice, to produce 2 separate sets of "tree data". The result is 2 trees with separate state, but with "branch.data" on both trees referencing the same shared data.
Note that you must be careful about using a "deep copy" if you are also using "branch.data" -- you probably don't want to deep copy the branch data ( in the example, that would create a copy of each "Person" object referenced by branch.data, which is not what you want -- you want a shared reference )