Checking tree-generating code for errors