#2959: Add more unit tests for tree matching, and test bottom-up calculator against hash-based calculator for consistency.