def traverse_field(metadata, kind, func, output_dir):
    """
    Given filled metadata, the `kind` of experiments data to process, a function that takes
    (model, batch size, DTR data dict, baseline data dict, output directory) and the output directory
    this function traverses each entry of the metadata with respect to the keys in DTR data dictionary (batch size)
    and calls `func` on each entry that records the data of experiments that have kind of `kind`.
    returns a tuple of status and message. This function will propagate the status of `func` if it fails in
    the middle of execution
    """
    for model in metadata.keys():
        dtr_dict = metadata[model]['dtr']
        baseline_dict = metadata[model]['baseline']
        # traverse wrt DTR data dict since we assume that DTR *fails less freqently than baseline
        # *: baseline will have more OOM error at large batch sizes and small budgets
        for batch_size in sorted(dtr_dict.keys()):
            for exp_kind in dtr_dict[batch_size]:
                if exp_kind == kind:
                    success, msg = func(model, batch_size, dtr_dict, baseline_dict, output_dir)
                    if not success:
                        return (False, msg)
    return (True, 'success')