fixed insertAtTreePath function