'given a with_polymorphic() argument, return the set of mappers it
represents.
Trims the list of mappers to just those represented within the given
selectable, if present. This helps some more legacy-ish mappings.'

def _mappers_from_spec(self, spec, selectable):

    if (spec == '*'):
        mappers = list(self.self_and_descendants)
    elif spec:
        mappers = set()
        for m in util.to_list(spec):
            m = _class_to_mapper(m)
            if (not m.isa(self)):
                raise sa_exc.InvalidRequestError(('%r    does    not    inherit    from    %r' % (m, self)))
            if (selectable is None):
                mappers.update(m.iterate_to_root())
            else:
                mappers.add(m)
        mappers = [m for m in self.self_and_descendants if (m in mappers)]
    else:
        mappers = []
    if (selectable is not None):
        tables = set(sql_util.find_tables(selectable, include_aliases=True))
        mappers = [m for m in mappers if (m.local_table in tables)]
    return mappers
