protected function copyIntoInternal(NodeInterface $referenceNode, string $nodeName, bool $detachedCopy): NodeInterface
    {
        if ($referenceNode->getNode($nodeName) !== null) {
            throw new NodeExistsException('Node with path "' . $referenceNode->getPath() . '/' . $nodeName . '" already exists.', 1292503467);
        }

        // On copy we basically re-recreate an existing node on a new location. As we skip the constraints check on
        // node creation we should do the same while writing the node on the new location.
        if (($referenceNode instanceof Node && !$referenceNode->willChildNodeBeAutoCreated($nodeName)) && !$referenceNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
            throw new NodeConstraintException(sprintf('Cannot copy "%s" into "%s" due to node type constraints.', $this->__toString(), $referenceNode->__toString()), 1404648177);
        }

        $copiedNode = $this->createRecursiveCopy($referenceNode, $nodeName, $detachedCopy);

        $this->context->getFirstLevelNodeCache()->flush();

        $this->emitNodeAdded($copiedNode);

        return $copiedNode;
    }