some code for Astree like iteration