traverse and calculate deepest node