if ($h and exists $h->{a} and exists $h->{a}{b} and exists $h->{a}{b}{foo})