Descendant property set and get

setDescendantProp (obj: any, dottedPropPath: any, value: any) {
const arr = dottedPropPath.split('.');
while (arr.length > 1) {
obj = obj[arr.shift()];
}
obj[arr[0]] = value;
}

getDescendantProp (obj: any, dottedPropPath: any) {
if (obj) {
const arr = dottedPropPath.split('.');
while (arr.length) {
obj = obj[arr.shift()];
if (obj === undefined) {
break;
}
}
}
return obj;
}

this.utilsService.setDescendantProp(this.model, fieldName, files[0]);