refactor tree producer