<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def handle_m2m_field(self, obj, field):
 """ while easymode follows inverse relations for foreign keys, for manytomayfields it follows the forward relation. While easymode excludes all relations to "self" you could still create a loop if you add one extra level of indirection. """

        
        if field.rel.through._meta.auto_created:#  and obj.__class__ is not field.rel.to:
            # keep approximate recursion level
            with recursion_depth('handle_m2m_field') as recursion_level:
                
                # a stack trace is better than python crashing.
                if recursion_level > getattr(settings, 'RECURSION_LIMIT', sys.getrecursionlimit() / 10):
                    raise Exception(MANY_TO_MANY_RECURSION_LIMIT_ERROR % 
                            (field.name, obj.__class__.__name__, field.rel.to.__name__))

                self._start_relational_field(field)

                s = RecursiveXmlSerializer()
                s.serialize( getattr(obj, field.name).iterator(), xml=self.xml, stream=self.stream)

                self.xml.endElement("field")