public function removeVersion($version)
    {
        $versionParser = new VersionParser();

        if ($version instanceof PackageInterface) {
            $normalizedVersion = $version->getVersion();
        } elseif (is_string($version)) {
            $normalizedVersion = $versionParser->normalize($version);
        } else {
            throw new \InvalidArgumentException(
                'You have to pass either an instance of PackageInterface or a version string to remove a version ' .
                'from this package object!'
            );
        }

        foreach ($this->getVersions() as $key => $attachedVersion) {
            if ($attachedVersion->getVersion() == $normalizedVersion) {
                unset($this->versions[$key]);
            }
        }

        return $this;
    }