Here's some java source code (gzipped tarball at the bottom) for a Tree Edit Distance algorithm that might be useful to you.
The page includes references and some slides that go through the "Zhang and Shasha" algorithm step-by-step and other useful links to get you up to speed.
Edit: While this answer was accepted because it pointed to the Zhang-Shasha algorithm, the code in the link has bugs. Steve Johnson and tim.tadh have provided working Python code. See Steve Johnson's comment for more details.