fix bug: panics
refactor tree
refactor tree