pub fn transform<F>(&mut self, func: &mut F)
    where
        F: FnMut(&mut Expr) -> Option<Expr>,
    {
        if let Some(e) = func(self) {
            *self = e;
            return self.transform(func);
        }
        for c in self.children_mut() {
            c.transform(func);
        }
    }
Recursively transforms an expression in place by running a function on it and optionally replacing it with another expression.
weld/src/ast/ast.rs