Check if value is an array before iterating.