<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def primary_mrna(entrystream, parenttype='gene'):
 """ Select a single mRNA as a representative for each protein-coding gene. The primary mRNA is the one with the longest translation product. In cases where multiple isoforms have the same translated length, the feature ID is used for sorting. This function **does not** return only mRNA features, it returns all GFF3 entry types (pragmas, features, sequences, etc). The function **does** modify the gene features that pass through to ensure that they have at most a single mRNA feature. """

    for entry in entrystream:
        if not isinstance(entry, tag.Feature):
            yield entry
            continue

        for parent in tag.select.features(entry, parenttype, traverse=True):
            mrnas = [f for f in parent.children if f.type == 'mRNA']
            if len(mrnas) == 0:
                continue
            _emplace_pmrna(mrnas, parent)
        yield entry