Tree building algorithm: one more optimization tweak