code: private void cleanUpHistoryTree(HistoryNode node) {
      if (node == null || node.children == null) {
        return;
      }
      
      Iterator<HistoryNode> iterator = node.children.iterator();
      while (iterator.hasNext()) {
        HistoryNode child = iterator.next();
        
        // clean up child
        cleanUpHistoryTree(child);
        
        // clean up current node;
        if (shouldRemoveNode(child)) {
          iterator.remove();
        }
      }
    }
docs: Clean up the Tree by DFS traversal.
  
  Remove the node that has no children and no notifications associated
  with them.
  @param node