Writing a utility function for freeing syntax trees and using it to fix
a memory leak.