I&#x27;m not using Nanopass directly, I&#x27;ve got my own similar framework (developed independently).<p>It is using an IR which allows to easily compare the visitor shapes (i.e., source AST, target AST, traversing order, omitted nodes), and if they do match and the second pass is not using results of any of the collectors from the first pass (too long to explain what collectors are, treat them as a kind of a constrained side effect), corresponding visitor nodes are chained together.<p>Deforestation is supposed to work on much lower level, and I&#x27;m not sure it&#x27;s possible to deduce the original visitor shapes and traversing order from an already lowered code.<p>A previous version of this framework is available on github, username &#x27;combinatorylogic&#x27; (it does not provide fusion or any other optimisations, because it&#x27;s dynamically typed; A glimpse of the IR of the next version can be seen in the recform AST library, see &#x27;ast2-...&#x27;). The current version will be published soon.