code: private void updateDates(Task parentTask)
     {
        if (parentTask.hasChildTasks())
        {
           Date plannedStartDate = null;
           Date plannedFinishDate = null;
  
           for (Task task : parentTask.getChildTasks())
           {
              updateDates(task);
              plannedStartDate = DateHelper.min(plannedStartDate, task.getStart());
              plannedFinishDate = DateHelper.max(plannedFinishDate, task.getFinish());
           }
  
           parentTask.setStart(plannedStartDate);
           parentTask.setFinish(plannedFinishDate);
        }
     }
docs: Recursively update parent task dates.
  
  @param parentTask parent task