<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_primary_type(ttypes, parent, logstream=stderr):
 """Check for multiple transcript types and, if possible, select one."""

    if len(ttypes) > 1:
        if logstream:  # pragma: no branch
            message = '[tag::transcript::primary_transcript]'
            message += ' WARNING: feature {:s}'.format(parent.slug)
            message += ' has multiple associated transcript types'
            message += ' {}'.format(ttypes)
            print(message, file=logstream)
        if 'mRNA' not in ttypes:
            message = (
                'cannot resolve multiple transcript types if "mRNA" is'
                ' not one of those types {}'.format(ttypes)
            )
            raise Exception(message)
        ttypes = ['mRNA']
    return ttypes[0]