From the OOP point of view, I think approach number 2 is the way to go. (Statics in general is often disapproving in OOP.)
As I understand it, a method uses this as root and then iterates through the rest of the tree without calling any instance methods? This is not so bad considering that the other nodes are of the same class, which means that the code is already used for all objects. (The method can access private members of other instances, etc.)
I believe that getSize , getHeight , getDepth , getPreOrder , getInOrder , getPostOrder and getLevelOrder can be implemented as appropriate recursive instance methods. (Correct me if I am wrong.)
The fourth option, which is not so bad, is to use a visitor template and have a NodeVisitor interface.
source share