Tree data structure implementation