To calculate the depth,  when removing a node,  give a depth of at least the depth of the removed node + 1 to the connected nodes