title: Dynamic question answer tree structure in mongodb
body: <p>I'm looking to build a question answer survey system where some questions will be based on the answer of the parent question. The hierarchy level of the questions can go any number of depth based on the questions. The questions and answers will be like the diagram shown here. </p>
  
  <p><a href="https://i.stack.imgur.com/H9BwK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H9BwK.png" alt="Question answer tree model"></a></p>
  
  <p>I'm looking to build this in mongodb and nodejs. I have checked the tree model in mongodb and I'm clueless on how to structure it as the next set of questions are depends on the answers. The questions should show based on what answer the user have selected and some answers may have multiple question sets below that as well (E.g.: Ans B).</p>
  
  <p>Can someone help me on the mongodb collection structure and how can I query the next set of questions and answers based on the previous answer given by the user?
  Any guidance is appreciated. Thanks</p>