Support faceting in entities and relations listings. 

@scott2b I was wondering whether you might have a second to review this; it turned out to be more of a mess than I expected. 

Potential extensions: 

- [ ] Status facets
- [ ] 'relations' facet that combines inbound and outbound.
JSONEncoder is actually quite smart about most of this stuff - it would handle traversal and iterables automatically. I really don't understand why it wouldn't handle generators the same way as lists and tuples - perhaps implied state changes?