refactor(tree): switched to class based implementation