I have a similar structure. For me, I do not have unique key for each node. So, after finishing changes on the TreeView, I delete all the relevant records from DB, and save all new records.
If you have unique keys, then I think you can do all you want with two SQL commands (assuming Firebird).
1) delete
2) update or insert
It is very intuitive .. .when you delete a node, you only have to delete the record with the unique key of the node.
When insert, a new unique key will be given.
When you change something, like changing position of a node so that its parent node is changed, then you need update.
Update or Insert (SQL) command will insert or update the content based on the key.