Rewrite ast for procedure and iterator chain'