First refactoring of working but crappy filtering-by-relation code.

The Gremlin pipeline used to reach the relation is now compiled once
for each filter, and reset for each new node. It's still probably
horribly inefficient, but it works for the time being.
Query sorting by relation property order is now working, though it
may be the worse code I've ever written. Currently only one order
predicate will work, and the implementation is probably dog-slow.
The Gremlin mailing list probably as some answers as to how to
improve this.