Add tree walking code