those 9 lines could be written as 

```
sifted = sift(y.args, is_sqrt)
a.append(sifted[True], sifted[False])
```

And you don't have to worry about whether the keys are there or not:

```
>>> d=sift([x],lambda w:w==x)
>>> d[True]
[x]
>>> d[False]
[]
```