Move the implementation of methods into static functions to avoid the common mistake of accessing the member variables of the wrong object when traversing the data structure.