'Called by both direct and indirect m2m traversal.'

def _get_path_info(self, direct=False):

    pathinfos = []
    int_model = self.rel.through
    linkfield1 = int_model._meta.get_field_by_name(self.m2m_field_name())[0]
    linkfield2 = int_model._meta.get_field_by_name(self.m2m_reverse_field_name())[0]
    if direct:
        join1infos = linkfield1.get_reverse_path_info()
        join2infos = linkfield2.get_path_info()
    else:
        join1infos = linkfield2.get_reverse_path_info()
        join2infos = linkfield1.get_path_info()
    pathinfos.extend(join1infos)
    pathinfos.extend(join2infos)
    return pathinfos
