Recursively iterating JSON object

const appleObjects = [
    {
  name: "pink", messages: [
      {id: "1", message: {color: "red"}},
      {id: "2", message: {color: "red2"}}
      ]},
      
      
    {name: "black",messages: [
        {id: "10", message: {color: "yellow1"}},
     {id: "20", message: {color: "yellow2"}}
        
        ]}
]

I want to recursively traverse and reduce it to the following:

[
    { name: "pink", id: "1", message: {color: "red"}},
    {name: "pink", id: "2", message: {color: "red2"}},
    { name: "black", id: "10", message: {color: "yellow1"}}
    {name: "black", id: "20", message: {color: "yellow2"}}
]

I tried following the thread from: Reduce JSON object containing JSON objects into an array of the form [Path, Value] but I’m unable to modify it to get the correct output.