protected function initNodeTrait(?NodeInterface $parent = null, ?string $name = null)
    {
        $this->nodeName = $name ?? spl_object_hash($this);

        if (!$parent) {
            $this->nodeRoot = $this;
            $this->nodeParent = $this;
        } else {
            $this->nodeRoot = $parent->getRoot();
            $this->nodeParent = $parent;
            /** @noinspection PhpParamsInspection */
            $parent->addChild($this);
        }
    }