collapse deep trees