Cleaner and faster tree builder, less code repetition.

The tree is built with far less code, and is faster (loop vs recursion). Also, less repetition of the fields for the nodes. Previously they were repeated over 3 different places, now the builder doesn't needs to know the fields, no need to remember updating it when they change.