def aggregate_repeated_calls(frame, options):
if frame is None:<EOL><INDENT>return None<EOL><DEDENT>children_by_identifier = {}<EOL>for child in frame.children:<EOL><INDENT>if child.identifier in children_by_identifier:<EOL><INDENT>aggregate_frame = children_by_identifier[child.identifier]<EOL>aggregate_frame.self_time += child.self_time<EOL>if child.children:<EOL><INDENT>aggregate_frame.add_children(child.children)<EOL><DEDENT>child.remove_from_parent()<EOL><DEDENT>else:<EOL><INDENT>children_by_identifier[child.identifier] = child<EOL><DEDENT><DEDENT>for child in frame.children:<EOL><INDENT>aggregate_repeated_calls(child, options=options)<EOL><DEDENT>frame._children.sort(key=methodcaller('<STR_LIT:time>'), reverse=True)  <EOL>return frame<EOL>
Converts a timeline into a time-aggregate summary.

Adds together calls along the same call stack, so that repeated calls appear as the same
frame. Removes time-linearity - frames are sorted according to total time spent.

Useful for outputs that display a summary of execution (e.g. text and html outputs)