Tree.add

Tree.add(node, parent=None)[source]

Add a node to the tree.

Parameters:
nodecompas.datastructures.TreeNode

The node to add.

parentcompas.datastructures.TreeNode, optional

The parent node of the node to add. Default is None, in which case the node is added as a root node.

Returns:
None
Raises:
TypeError

If the node is not a compas.datastructures.TreeNode object. If the supplied parent node is not a compas.datastructures.TreeNode object.

ValueError

If the node is already part of another tree. If the supplied parent node is not part of this tree. If the tree already has a root node, when trying to add a root node.