Add count_by() and find_last()

`has_key()` was removed in Python 3. You could replace with `if key in ret` or use something like this:

```python
ret.setdefault(key, 0)
ret[key] += 1
```