private function canAddTarget($target, $mode)
    {
        // Mode is set to ignore existing targets
        if ($mode === self::DUPLICATE_IGNORE) {
            return false;
        }

        // Error if we're not allowed to overwrite or can't remove the existing target
        if ($mode !== self::DUPLICATE_OVERWRITE || !$this->filesystem->remove($target)) {
            throw new \RuntimeException(sprintf('Installation target "%s" already exists', $target));
        }

        return true;
    }