In the Mechanical application, when the "Model" object is selected in the tree, the model ribbon tab allows the user to select "Named Selection". If the parent Named Selections object does not already exist in the tree, clicking this button will create the parent object and a child named slection object. If the parent object already exists, then this button just creates a named selection object. There are other examples of this in Mechanical, such as cross sections, and contacts (depending on what is currently selected in the tree).
How can we replicate this behaviour in an ACT extension toolbar?
I understand we can use to define functions for any toolbar button.
<callbacks>
<onclick>createChildObject</onclick>
</callbacks>
What would be the python code that checks for the presence of the parent object, and creates it if it doesn't exist?