function getHeadersExamples(msg) {
  const examples = msg.examples();
  if (Array.isArray(examples) && examples.some(e => e.headers)) {
    // Instead of flat or flatmap use this.
    const messageExamples = _.flatMap(examples)
      .map(e => {
        if (!e.headers) return;
        return {
          name: e.name,
          summary: e.summary,
          example: e.headers,
        };
      })
      .filter(Boolean);

    if (messageExamples.length > 0) {
      return messageExamples;
    }
  }

  const headers = msg.headers();
  if (headers?.examples()) {
    return headers.examples().map(example => ({ example }));
  }
}
Extracts example from the message header
@msg {object} - Parser Message function
@returns {object}