public static function getLastElementsPaths(array $array, $separator = '.', $parentPath = '', $stopIfMatchedBy = '')
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        if (!empty($stopIfMatchedBy)) {
            $stopIfMatchedBy = self::makeArray($stopIfMatchedBy);
        }

        $paths = [];

        foreach ($array as $key => $value) {
            $path = $key;
            $stopRecursion = false;
            $valueIsArray = is_array($value);

            /*
             * If the path of parent element is delivered,
             * I have to use it and build longer path
             */
            if (!empty($parentPath)) {
                $pathTemplate = '%s%s%s';
                $path = sprintf($pathTemplate, $parentPath, $separator, $key);
            }

            /*
             * Check if the key or current path matches one of patterns at which the process should be stopped,
             * the recursive not used. It means that I have to pass current value and stop processing of the
             * array (don't go to the next step).
             */
            if (!empty($stopIfMatchedBy)) {
                foreach ($stopIfMatchedBy as $rawPattern) {
                    $pattern = sprintf('|%s|', $rawPattern);

                    if (preg_match($pattern, $key) || preg_match($pattern, $path)) {
                        $stopRecursion = true;

                        break;
                    }
                }
            }

            /*
             * The value is passed to the returned array if:
             * - it's not an array
             * or
             * - the process is stopped, recursive is not used
             */
            if (!$valueIsArray || ($valueIsArray && empty($value)) || $stopRecursion) {
                $paths[$path] = $value;

                continue;
            }

            // Let's iterate through the next level, using recursive
            if ($valueIsArray) {
                $recursivePaths = self::getLastElementsPaths($value, $separator, $path, $stopIfMatchedBy);
                $paths += $recursivePaths;
            }
        }

        return $paths;
    }