clear ArrayList when loop to last leaf