unsure if its the right tool for the job, but i have been using: https://github.com/stefanpenner/esprima-ast-equality in various code matching test contexts with good success. The output can be a bit verbose though.