Refactored tree set algebra.