def check_fields_match(msg1, msg2):
    """Check fields in msg1 match fields in msg2."""

    def _check_eq_or_none(fld1, fld2):
        return fld1 is None or fld2 is None or fld1 == fld2

    match = True
    for field in msg1.fields:
        fld1 = getattr(msg1, field.name)
        fld2 = getattr(msg2, field.name)
        match = match & _check_eq_or_none(fld1, fld2)
    return match