This is a recursive function, I thought variable names taking returned values were sufficient to understand what's going on home. By the way, the function is already well-commented...I can add another comment, but that'd be simply too much, I think. Anyway, let me know what you think. 

Basically, you analyze the binary AST of the expression and, for each node, you try to understand whether the subtree rooted on the left and the subtree rooted on the right use the same iteration variables