newFields.forEach((newField) => {
   let exitingFieldIndex = _.findIndex(existingFields, (existingField) => {
     return existingField.identifier === newField.identifier;
   });
   if (exitingFieldIndex !== -1) {
     //if existing field and new field are regions insert region fields
     if (ModelUtils.isRegion(newField) && ModelUtils.isRegion(existingFields[exitingFieldIndex])) {
       this.addFieldsToExistingFields(newField.fields, existingFields[exitingFieldIndex].fields);
     }
     // add next new field after the existing field
     insertPosition = exitingFieldIndex + 1;
   } else {
     existingFields.splice(insertPosition, 0, this.flattenDefinitionProperty(newField));
     insertPosition++;
   }
 });
 /**
  * Flattens a definition property and adds it to the flat model and model map.
  * @param definitionProperty
  * @param parentId
  */
 flattenDefinitionProperty(definitionProperty, parentId) {
   let definitionModelProperty = new DefinitionModelProperty(definitionProperty);
   if (ModelUtils.isRegion(definitionProperty)) {
     definitionModelProperty.fields.forEach((field, index, arr) => {
       arr[index] = this.flattenDefinitionProperty(field, definitionProperty.identifier);
     });
   }
   if (parentId) {
     definitionModelProperty.parentId = parentId;
   }
   this.flatDefinitions.push(definitionModelProperty);
   this.flatModelMap[definitionProperty.identifier] = definitionModelProperty;
   return definitionModelProperty;
 }
 it('should recognize if a field is not a region', () => {
   let field = ViewModelBuilder.createField('field1', 'EDITABLE', 'text', 'field 1', true, true, []);
   let isRegion = ModelUtils.isRegion(field);
   expect(isRegion).to.be.false;
 });
 it(' should recognize the region type fields', () => {
   let region = ViewModelBuilder.createRegion('region1', 'region 1', 'EDITABLE', false, false);
   let isRegion = ModelUtils.isRegion(region);
   expect(isRegion).to.be.true;
 });