'Return a list of CommentTuples in tree insertion order.
Also add a MissingChildrenTuple to the end of the list if there
are missing root level comments.'

def get_comment_order(self):

    with g.stats.get_timer('comment_tree.get.1') as comment_tree_timer:
        comment_tree = CommentTree.by_link(self.link, comment_tree_timer)
        sort_name = self.sort.col
        sorter = get_comment_scores(self.link, sort_name, comment_tree.cids, comment_tree_timer)
        comment_tree_timer.intermediate('get_scores')
    if isinstance(self.sort, operators.shuffled):
        top_level_ids = comment_tree.tree.get(None, [])
        top_level_scores = [sorter[comment_id] for comment_id in top_level_ids]
        shuffle(top_level_scores)
        for (i, comment_id) in enumerate(top_level_ids):
            sorter[comment_id] = top_level_scores[i]
    self.timer.intermediate('load_storage')
    comment_tree = self.modify_comment_tree(comment_tree)
    self.timer.intermediate('modify_comment_tree')
    (initial_candidates, offset_depth) = self.get_initial_candidates(comment_tree)
    comment_tuples = self.get_initial_comment_list(comment_tree)
    if comment_tuples:
        comment_tuple_ids = {comment_tuple.comment_id for comment_tuple in comment_tuples}
        initial_candidates = [comment_id for comment_id in initial_candidates if (comment_id not in comment_tuple_ids)]
    candidates = []
    self.update_candidates(candidates, sorter, initial_candidates)
    self.timer.intermediate('pick_candidates')
    while (candidates and (len(comment_tuples) < self.max_comments)):
        (sort_val, comment_id) = heapq.heappop(candidates)
        if (comment_id not in comment_tree.cids):
            continue
        comment_depth = (comment_tree.depth[comment_id] - offset_depth)
        if (comment_depth >= self.max_depth):
            continue
        child_ids = comment_tree.tree.get(comment_id, [])
        comment_tuples.append(CommentTuple(comment_id=comment_id, depth=comment_depth, parent_id=comment_tree.parents[comment_id], num_children=comment_tree.num_children[comment_id], child_ids=child_ids))
        child_depth = (comment_depth + 1)
        if (child_depth < self.max_depth):
            self.update_candidates(candidates, sorter, child_ids)
    self.timer.intermediate('pick_comments')
    top_level_not_visible = {comment_id for (sort_val, comment_id) in candidates if ((comment_tree.depth.get(comment_id, 0) - offset_depth) == 0)}
    if top_level_not_visible:
        num_children_not_visible = sum(((1 + comment_tree.num_children[comment_id]) for comment_id in top_level_not_visible))
        comment_tuples.append(MissingChildrenTuple(num_children=num_children_not_visible, child_ids=top_level_not_visible))
    self.timer.intermediate('handle_morechildren')
    return comment_tuples
