A HoH can go to varying depths. Do you want to traverse the whole HoH to find the deepest element, or do you know the chain you want to go down? The basic strategy is: if a value is a ref (
ref $href->{$key} eq 'HASH') then descend a level (
$href = $href->{$key}), increment your depth counter, and look again. The only tricky part is determining which keys you look at.
Caution: Contents may have been coded under pressure.