WordPress File wp-includes/class-wp-query.php

WP_Query::reset_postdata()

After looping through a nested query, this function restores the $post global to the current post in this query.