# A max depth watermark and a path representing that depth my ($max, $path) = (0, ''); # Work queue # 0 => path, 1 => depth, 2 => last visited leaf my @work = map [$_, 1, $_], keys %greater;