Close tree nodes before search