Parameterized print function in tree reporter

Makes it possible to inject a different print function in tests, verifying tree
reporter's behaviour.