Extract replace logic as `Ember.EnumerableUtils._replace`