# tool to insert nodes in a tree with queries

I have a tree where each node has a type. Multiple nodes can have the same type.

I want to insert new nodes in this tree at some specific positions specified by queries, such as :

• Insert the node next to the lowest and left most child of type 1
• Insert the node as child of root after the last child of root of type 2
• etc..

Is there an existing query-like language that does that ?

I found this (used for biology), and this, which are usefull for selecting nodes, not inserting, and don't seem to be used a lot.