/**
* Adds a node to this node
*
* @param NodeInterface $node nodes
*
* @return $this
*/
public function add(NodeInterface $node)
{
$this->rawNodes[$node->getNodeIdentifier()] = $node;
$parentId = $node->getParentNodeIdentifier();
if ($parentId) {
$parent = $this->rawNodes[$parentId];
$parent->addChild($node);
$parent->setChildren($this->sort($parent->getChildren()));
$node->setParent($this->rawNodes[$parentId]);
} else {
$this->treeNodes[$node->getNodeIdentifier()] = $node;
}
return $this;
}