Extract type-checking to support `namedtuple`.

Dunno whether it is a wide solution to support namedtuple :(
So, this is going to miss on other subclasses of tuple that aren't namedtuple. I don't know how many of these exist but since we're a framework and should work with whatever other legal Python code people want to throw at us, this test needs to be better.

What we really need to be able to determine here are the following things:
- Is `data` a namedtuple?
- Is `data` a tuple or non-namedtuple subclass thereof?
- Is `data` a list?
- Is `data` a dict?

The last two are straightforward enough.

To figure out the first, we need to peek at how namedtuple works and do some duck typing. Annoyingly, namedtuple classes are constructed at runtime and inherit from tuple without using any sort of intermediate superclass, as would any other custom subclasses of tuple. So we should check this with something like this:

```
def is_namedtuple(thing):
    return isinstance(thing, tuple) and hasattr(thing, '_fields')
```

Then checking whether something is a non-namedtuple tuple is just `isinstance(thing, tuple) and not is_namedtuple(thing)`.