[605] Be more defensive when building the tree