optimize wordpress rewrite rule regex

With all part optional with ?, you obtain one rule to rule them all :

add_rewrite_rule(
    '^cities/(.*)/(browse)?/?(.*)?/?(.*)?/?(.*)?/?(.*)?/?',
    'index.php?city_name=$matches[1]&cat_name[]=$matches[3]&cat_name[]=$matches[4]&cat_name[]=$matches[5]',
    'top'
);

but the [] cannot work with the WordPress logic then you need to define the rewrite tag with a number. try that :

add_rewrite_tag("%cat_name.%", "([^&]+)");

add_rewrite_rule(
    '^cities/([^/]*)/(browse)?/?([^/]*)?/?(^/)?/?([^/]*)?/?([^/]*)?/?',
    'index.php?city_name=$matches[1]&cat_name1=$matches[3]&cat_name2=$matches[4]&cat_name3=$matches[5]',
    'top'
);