Model.filter not generating correct SQL for join clause
Sorry, 3.12.0 seems to work, closing. I was using 3.10 OK, It's not fixed. Actually it randomly happens each time you restart the flask server. I think the reason is in function of  peewee.ModelSelect.filter().
target code is:
```python
        dq_joins = set()
        while q:
            curr = q.popleft()
            if not isinstance(curr, Expression):
                continue
            for side, piece in (('lhs', curr.lhs), ('rhs', curr.rhs)):
                if isinstance(piece, DQ):
                    query, joins = self.convert_dict_to_node(piece.query)
                    dq_joins.update(joins)
```

I can't understand why you use set() to define dq_joins? if use list(), this error will disappear. Thanks for the analysis. Yeah, it looks like the use of `set` is causing problems with the ordering of the joins. I will take a look! Fixed. Thanks! peewee has the lowest open-issue/star ratio in all the repositories I have seen on GitHub. ^_^
I have three models in a heritical order:

```python
class CrawlProject(Model):
    name = CharField()

class CrawlGroup(Model):
    name = CharField()
    project = ForeignKeyField(CrawlProject)

class CrawlRule(Model):
    name = CharField()
    group = ForeignKeyField(CrawlGroup)
```
    
Given the following code:

```python
CrawlRule.filter(group__project__id=47)
```

Then I got the following error:

```
 File "/home/tiger/repos/baelish/.venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 378, in _query
   db.query(q)
 File "/home/tiger/repos/baelish/.venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 280, in query
   _mysql.connection.query(self, query)
eewee.OperationalError: (1054, "Unknown column 't3.project_id' in 'on clause'")
```

The generated SQL is like:
```SQL
SELECT `t1`.`id` FROM `crawl_rule` AS `t1`
INNER JOIN `crawl_project` AS `t2`ON (`t3`.`project_id` = `t2`.`id`)
INNER JOIN `crawl_group` AS `t3` ON (`t1`.`group_id` = `t3`.`id`)
WHERE ((`t3`.`project_id` = 47)) LIMIT 20 OFFSET 0
```
It seems that `t3` was referenced before defined.

actually, simply swapping the inner joins works:

```SQL
SELECT `t1`.`id` FROM `crawl_rule` AS `t1`
INNER JOIN `crawl_group` AS `t3` ON (`t1`.`group_id` = `t3`.`id`)
INNER JOIN `crawl_project` AS `t2`ON (`t3`.`project_id` = `t2`.`id`)
WHERE ((`t3`.`project_id` = 47)) LIMIT 20 OFFSET 0
```
