widl: Factor out the finding of a registered type to reduce code duplication.