Dynamically populate the menu when a new category is created

yes, of course it is possible to do.
Here is the code to get all the categories on a page load, this code is prepared to go until the 3rd category generation.

$cats = get_categories( array('taxonomy' => 'product_cat', 'hide_empty' => true) );
foreach ($cats as $key => $cat):
    if ($cat->parent == 0):
        echo $cat->name;
        foreach ($cats as $key => $cat2):
            if ($cat2->parent == $cat->term_id):
                echo $cat2->name;
                foreach ($cats as $key => $cat3):
                    if ($cat3->parent == $cat2->term_id):
                        echo $cat3->name;
                    endif;
                endforeach;
            endif;
        endforeach;
    endif;
endforeach;