tree work calculating paths