You can just add a check:
if ( ! empty ( $post->post_parent ) )
{
$parent_title = get_the_title($post->post_parent);
echo "<h1>$parent_title</h1>";
}
or use setup_postdata()
:
setup_postdata( $post->post_parent );
the_title( /* arguments here*/ );
wp_reset_postdata();