added function to set all parent links in tree