Generalise ast inspection to n-ary expressions.
Merge pull request #348 from OP2/ast_fixes

Generalise ast inspection to n-ary expressions.