I checked with x-debug, when the condition $form_id === $element[\'id\'] is met, the loop should be stopped but it jumps to this line if ( $element ).
$form_id === $element[\'id\']
if ( $element )