add function to tree