fixing TreePair.is_tree()

Also adding a bunch of doctests.