toStringTree rewritten into C++