The Perl 5 module B::Utils provides functions that make it easier to manipulate the op tree.