generalize treePath