using stackoverflow tip to kill entire tree