protected function removeCopies($targetRoot, array $pathMap)
    {
        if (empty($pathMap)) {
            return;
        }

        $actions = [];

        // Check the file map first and make sure we only remove our own symlinks.
        foreach ($pathMap as $targetPath) {
            $target = $this->filesystem->normalizePath($targetRoot . '/' . $targetPath);

            if (!file_exists($target)) {
                continue;
            }

            $actions[] = $target;
        }

        // Remove the symlinks if everything is ok.
        foreach ($actions as $target) {
            $this->logRemove($target);

            $this->filesystem->unlink($target);

            $this->removeEmptyDirectories(dirname($target), $targetRoot);
        }
    }