<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_m2m_field(model, sender):
 """ Get the field name from a model and a sender from m2m_changed signal. """

    for field in getattr(model, '_tracked_fields', []):
        if isinstance(model._meta.get_field(field), ManyToManyField):
            if getattr(model, field).through == sender:
                return field
    for field in getattr(model, '_tracked_related_fields', {}).keys():
        if isinstance(model._meta.get_field(field), ManyToManyField):
            if getattr(model, field).through == sender:
                return field