Update maximum distance in a binary tree