perhaps just change this to 

if (is_array($value) && isset($currentValue[$name]) && is_array($currentValue[$name])) {