public function calculateAnswers($treeData, $answers, $parent = null, $textAnswers = array())
{
foreach ($treeData[$parent] as $node) {
if (isset($answers[$node->id])) {
$textAnswers[$node->question] = $node->response_type->getDisplayValueforResponse($answers[$node->id]);
}
if (isset($treeData[$node->id])) {
$textAnswers = $this->calculateAnswers($treeData, $answers, $node->id, $textAnswers);
}
}
return $textAnswers;
}