How to properly reset a nested WP_Query query

This touches upon an answer provided here Loop within a loop? except I posted the full code:

$query = new WP_Query($args);

while ($query->have_posts()) :

    // initialization for $inner_args & backup the current global $post
    global $post;
    $backup = $post; 
    $inner_query = new WP_Query($inner_args);

    while ($inner_query->have_posts()) :
        // do something
    endwhile;
    $inner_query->reset_postdata();
    // restore the global $post from the previously created backup
    $post = $backup;

endwhile;
$query->reset_postdata();

The important thing here is you are setting the current post as a backup, because when the inner nested WP_Query postdata is set up, the prior loop’s is lost. After the inner query finishes looping, you can set the post back to your backup and continue in the “parent” loop.