def extract_events(json_node, collect_function):
    """Depth-first search of events returning them as a list of lists, therefore implicitly saving
    the parent-child relationship between events.
    Args:
      json_node: Json representation of the current events.
      collect_function: Function that collects the desired data for events.
    Returns:
      A list of lists representation that contains all the events traversed by the depth-first
      search.
    """
    if len(json_node) == 0:
        return []

    extracted_events = list()
    child_events = json_node['children']

    if child_events == []:
        extracted_events.extend([collect_function(json_node), []])
    else:
        extracted_events.extend([collect_function(json_node), [
                                extract_events(ce, collect_function) for ce in child_events]])

    return extracted_events