refactor out range handling for iterators into a module

This pull request removes the tricky range handling code out into a module.
This makes it much easier to handle ranges correctly, and is backwards compatible with all the ways ranges have been specified in `level-*`

admittedly, this code is less cpu optimal than what was there previously - but it's also a lot simpler,
and raw performance is not the priority - it's more of a guide for implementing other leveldowns,
so I think simplicity is more important.
dude, spacing! space after `if`, newline after the parns, preferably blank lines between items that are not tightly related just to stop it feeling like economy class in here