Updated Treeage function with example