<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def models(self, model=None):
 """ Returns the tables that this query is referencing. :return [ <subclass of Table>, .. ] """

        for query in self.__queries:
            if isinstance(query, orb.Query):
                yield query.model(model)
            else:
                for model in query.models(model):
                    yield model