public static function walk(
        array &$array,
        callable $callback,
        $recurse = false,
        $path = '',
        $considerLeaves = true
    ) {
        $path = trim($path, '.');

        foreach ($array as $key => $value) {
            if (is_array($value) && $recurse) {
                if ($considerLeaves === false && !static::hasNested($value)) {
                    $callback($key, $value, $array, $path);
                    continue;
                }

                $deeperPath = $key;

                if ($path !== '') {
                    $deeperPath = vsprintf('%s.%s', [$path, $key]);
                }

                static::walk(
                    $array[$key],
                    $callback,
                    true,
                    $deeperPath,
                    $considerLeaves
                );
                continue;
            }

            $callback($key, $value, $array, $path);
        }

        return $array;
    }