code: function applyPatches (versions) {
      versions = sortVersions(versions, 'ASC')
  
      let state = []
      // iterate patches to the final one => get previous commit state
      versions.forEach((v) => {
        v.changes.forEach((c) => {
          if (c.operation === 'insert') {
            return state.push({
              entityId: c.entityId,
              entitySet: c.entitySet,
              entity: parse(c.serializedDoc),
              path: c.path
            })
          }
  
          if (c.operation === 'remove') {
            state = state.filter((e) => e.entityId !== c.entityId)
            return
          }
  
          const entityState = state.find((e) => e.entityId === c.entityId)
          applyPatch(entityState.entity, parse(c.serializedPatch), c.entitySet, documentModel)
        })
      })
      return state
    }
docs: apply all patches in collection and return final state of entities