WinningRev and Merge Improvements

The existing implementations of winningRev and the revtree merge algorithm only consider the leftmost path through each revision tree.  I think this works if you're only manipulating data in PouchDB, but once you start to replicate with CouchDB (for example), the trees start to get complex and the existing algorithms don't make the correct decision.

The changes I made pass all existing (unmodified) tests, plus CouchDB's suite of revtree merge tests which I added to this codebase, which the old code failed on.  The tests and code are split into separate commits so you can compare the old algorithm with new tests and expected results.

This fixes my issues in #314 (which are included as a test as well), and I believe should address @trokster's problems in #293.  I'm not entirely convinced it's ready for prime time as the changes are so big, but if anyone else can help bang on it and see if everything is still working, that would be great.