fix infinite loop in tree construction, add early termination @ 3s timeout