'A helper function for ``select``, which creates a new index for
a given set of attributes (aka restriction keys).'

def _add_index(self, restr_keys):

    for key in restr_keys:
        if (not hasattr(EdgeI, key)):
            raise ValueError((u'Bad    restriction:    %s' % key))
    index = self._indexes[restr_keys] = {}
    for edge in self._edges:
        vals = tuple((self._get_type_if_possible(getattr(edge, key)()) for key in restr_keys))
        index.setdefault(vals, []).append(edge)
