Add tstree implimentation and tests