def merge_consecutive_self_time(frame, options):
if frame is None:<EOL><INDENT>return None<EOL><DEDENT>previous_self_time_frame = None<EOL>for child in frame.children:<EOL><INDENT>if isinstance(child, SelfTimeFrame):<EOL><INDENT>if previous_self_time_frame:<EOL><INDENT>previous_self_time_frame.self_time += child.self_time<EOL>child.remove_from_parent()<EOL><DEDENT>else:<EOL><INDENT>previous_self_time_frame = child<EOL><DEDENT><DEDENT>else:<EOL><INDENT>previous_self_time_frame = None<EOL><DEDENT><DEDENT>for child in frame.children:<EOL><INDENT>merge_consecutive_self_time(child, options=options)<EOL><DEDENT>return frame<EOL>
Combines consecutive 'self time' frames