Tree building algorithm: reduce temporary storage size by factor of 2