export function flatten<T>(arr: T[], property: keyof T): T[] {
  if (!Array.isArray(arr)) {
    return arr || [];
  }

  return arr.reduce(
    (acc, curr) => acc.concat(Array.isArray(curr[property]) ? flatten((curr[property] as unknown) as T[], property) : curr),
    []
  );
}
