Recursive function on n-descendent

Recursive function on n-descendent

Hi

I want to write recursive jquery function to iterate through below JSon

[{"newQuestionid":"3451602225724915","newDQGroupID":0,"newDQAtrributesID":0,"newQuestion":"A","newParent":0,"newParentTrigger":[],"newOrder":0,"newRequired":false,"newAttributesID":0,"newType":"Free Text","newAttributes":[]},{"newQuestionid":"2750413003607790","newDQGroupID":0,"newDQAtrributesID":0,"newQuestion":"B","newParent":0,"newParentTrigger":[],"newOrder":0,"newRequired":false,"newAttributesID":0,"newType":"Free Text","newAttributes":[]},{"newQuestionid":"4498200815351845","newDQGroupID":0,"newDQAtrributesID":0,"newQuestion":"C","newParent":"A","newParentTrigger":[],"newOrder":0,"newRequired":false,"newAttributesID":0,"newType":"Free Text","newAttributes":[]},{"newQuestionid":"7903861049907270","newDQGroupID":0,"newDQAtrributesID":0,"newQuestion":"D","newParent":"B","newParentTrigger":[],"newOrder":0,"newRequired":false,"newAttributesID":0,"newType":"Free Text","newAttributes":[]},{"newQuestionid":"4353708674607597","newDQGroupID":0,"newDQAtrributesID":0,"newQuestion":"E","newParent":"C","newParentTrigger":[],"newOrder":0,"newRequired":false,"newAttributesID":0,"newType":"Free Text","newAttributes":[]}]

here i want to recursively iterate through above json and bind the result on page in table(td/tr) form.

here i want find newQuestion and newParent properties from above Json. if newParent is 0 then newQuestion value will get bind as top element. below is how bind will be done in html table on page.

Parent 1 -A (A is value of newQuestion property, it will come on top as newParent property value is 0)
Child Row 1-C (C is value of newQuestion, as it will come under A because its newParent property value is A. A is parent of C)
Child-child Row 1 -E (E is value of of newQuestion, as it will come under C because its newParent property value is C. C is parent of E)

Parent 2-B (B is value of newQuestion property, it will come on top as newParent property value is 0)
Child Row 1-D (D is value of newQuestion, as it will come under B because its newParent property value is B. B is parent of D)

In this way there will be infinite loop and there can be n number of child and parent.