refactoring tree.view.js