Update tree and add function