Optimizations that consumes less time generating the tree