Recursively pre-populate Webforms
The main problem is you are not passing the form array by reference so your values are never coming back into the form. Try this (note the ampersand on $form['submitted']):

function my_module_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $submitted = &amp;$form['submitted'];
  prepopulate_form($submitted, $value_array);
}


Otherwise you are only modifying the $submitted variable and not the actual form. 

Alternatively, you could also just pass $form['submitted'] into the prepopulate_form() function instead of using the $submitted variable and that would also work.

Plus, you are using $value_array, which does not exist, so you will need to pass actual values in.