Moved logic to toggle nodes into tree view.