public function add($item, $prepend = false)
    {
        if (!$item instanceof ChildNodeInterface) {
            $details = is_object($item) ? get_class($item) : gettype($item);
            throw new InvalidArgumentException(
                "NodeCollection accepts only objects implementing ChildNodeInterface, $details given."
            );
        }
        $old = $item->parent();
        if ($old === $this->parentNode) {
            return $this;
        } elseif ($old !== null) {
            $item->detach();
        }
        $this->checkUnlocked($item);
        parent::add($item, $prepend);
        $item->internalSetParent($this->parentNode);

        return $this;
    }