code: def _filter_by_m2m_schema(self, qs, lookup, sublookup, value, schema, model=None):
          
          model = model or self.model
          schemata = dict((s.name, s) for s in model.get_schemata_for_model())   # TODO cache this dict, see above too
          try:
              schema = schemata[lookup]
          except KeyError:
              # TODO: smarter error message, i.e. how could this happen and what to do
              raise ValueError(u'Could not find schema for lookup "%s"' % lookup)
          sublookup = '__%s'%sublookup if sublookup else ''
          return {
              'attrs__schema': schema,
              'attrs__choice%s'%sublookup: value,  # TODO: can we filter by id, not name?
          }
docs: Filters given entity queryset by an attribute which is linked to given
          many-to-many schema.