Last fixes to query order. More test cases.
Allowing B to be specified in template arguments for tree. Add function to count number of elements in subtrees. Some bugs to catch.