How to populate the document, response document and response to response when a key is called

Dear all,

I have created a system with 3 type of forms, document, response document and response to response. Each of this form is related to each by a key called “sponsor” field.

I wanted to populate the data to format like this :

Level 1 Mr. A

Level 2 Mr. A1

              Mr. A2

              Mr. A3

Level 3 Mr. A11

              Mr. A31

              Mr. A32

Level 4 Mr. A321

The example above is populated from the document and response document. Mr A is the parent document, Mr A1, A2 and A3 is reponse from Mr A. Mr A11 is response from Mr. A1. Mr A31 and A32 are the response from Mr A3. Mr A321 is the response from Mr A32.

My problem now is I do not have any idea how the populate the document and response document into a format like this.

Can anybody please help?