private function resolveWithHash(ParsedFileID $parsedFileID)
    {
        // Try to find a version for a given stage
        /** @var File $file */
        $file = Versioned::withVersionedMode(function () use ($parsedFileID) {
            Versioned::set_stage($this->getVersionedStage());
            return File::get()->filter(['FileFilename' => $parsedFileID->getFilename()])->first();
        });

        // Could not find a valid file, let's bail.
        if (!$file) {
            return null;
        }

        $dbHash = $file->getHash();
        if (strpos($dbHash, $parsedFileID->getHash()) === 0) {
            return $parsedFileID;
        }

        // If we found a matching live file, let's see if our hash was publish at any point

        // Build a version filter
        $versionFilters = [
            ['"FileHash" like ?' => DB::get_conn()->escapeString($parsedFileID->getHash()) . '%'],
            ['not "FileHash" like ?' => DB::get_conn()->escapeString($file->getHash())],
        ];
        if ($this->getVersionedStage() == Versioned::LIVE) {
            // If we a limited to the Live stage, let's only look at files that have bee published
            $versionFilters['"WasPublished"'] = true;
        }

        $oldVersionCount = $file->allVersions($versionFilters, "", 1)->count();
        // Our hash was published at some other stage
        if ($oldVersionCount > 0) {
            return new ParsedFileID($file->getFilename(), $file->getHash(), $parsedFileID->getVariant());
        }

        return null;
    }