refactor tree package