add null check in tree updateNode