Subtree collapse results in orphaned nodes without link to its parent

Thanks Walter . I tried both combination but it is not working , with these methods, T1D1 position is always on top of the T1D2 and it is not getting aligned with other child nodes to XTM. I observed that if collapse and then expand XTM then it is T1D1 is aligning properly with other nodes . Is that something can be done programmatic, say collapse and then expand a node in the button click of custom tree expander button?