Add tree logic