<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _filter(msgdata, mailparser, mdfolder, mailfilters):
 """Filter msgdata by mailfilters"""

    if mailfilters:
        for f in mailfilters:
            msg = mailparser.parse(StringIO(msgdata))
            rule = f(msg, folder=mdfolder)
            if rule:
                yield rule
    return