You could use SavePanelState and RecallPanelState for this. These functions will take a snap shot of the values of all the controls on your panel and save that data to a file you specify. The "value" of a tree control is pretty much the whole state of the tree control, including the items and their expanded/collapsed state. Since this function saves the state of the whole panel, and you may only want to save the state of the tree control, you could create a temporary panel at the beginning and end of your program that you copy the tree control to and then save and recall the state of that temporary panel.
I've attached a sample program that demonstrates SavePanelState and RecallPanelState.
Hope this helps,
- jared