In some toolkits, recording the expand/collapse by mouse-clicking on the "+/-" button does not play back reliably or properly.
In such cases, clicking on the rootiest tree node and using keyboard arrow keys to navigate/expand is a workaround that can record/playback properly.