code: private void updateWork(Task parentTask)
     {
        if (parentTask.hasChildTasks())
        {
           ProjectProperties properties = m_project.getProjectProperties();
  
           Duration actualWork = null;
           Duration baselineWork = null;
           Duration remainingWork = null;
           Duration work = null;
  
           for (Task task : parentTask.getChildTasks())
           {
              updateWork(task);
  
              actualWork = Duration.add(actualWork, task.getActualWork(), properties);
              baselineWork = Duration.add(baselineWork, task.getBaselineWork(), properties);
              remainingWork = Duration.add(remainingWork, task.getRemainingWork(), properties);
              work = Duration.add(work, task.getWork(), properties);
           }
  
           parentTask.setActualWork(actualWork);
           parentTask.setBaselineWork(baselineWork);
           parentTask.setRemainingWork(remainingWork);
           parentTask.setWork(work);
        }
     }
docs: See the notes above.
  
  @param parentTask parent task.