Encontre propriedade em objeto aninhado

const data = {
  "user": {
    "name": "Zahid Hasan",
    "email": "[email protected]"
  },
}

const findPropFromObj = (object, key) => {
  if (object.hasOwnProperty(key)) {
    return object[key];
  }

  for (const k of Object.keys(object)) {
    if (typeof object[k] === "object") {
      const o = findPropFromObj(object[k], key);
      if (o !== null && typeof o !== 'undefined')
        return o;
    }
  }

  return null;
}

console.log(findPropFromObj(data, 'email'))
Said HR