tree.h: K&R formatting and typo cosmetics
tree-test: Refactor and plug memory leaks

With the most annoying memory leak found by Derek Buitenhuis.