Using Panel.add to add a new node and preserve node in Model

If we were to add a node problematically to another node using the Panel.add function, how we we ensure that the newly added node get added to the Diagram.model so that we we serialize the diagram to JSON, the newly added node shows up a sub-node of the parent node.

Nodes cannot be added to other nodes.

If you mean adding panels to other nodes, what you are looking for are Item Arrays.

Or to add a new node to a diagram, call Model.addNodeData,, with a new JavaScript object.