bug 773612, rearrange the for loop so that loc is defined when used. rs=me, bustage
bug 1044761, don't remove trees twice, rs=sparky