diagtool: refactor TreeView to resemble C++

Replace lots of old-school parameter passing with neat class members.
No attempt made yet to modernize loops, but it's a start.