def get_previous_root(batches, index):
    """
    Returns the root on which we want to apply the batch.
    In case it is the first batch, None is returned.
    """
    previous_batch_index = batches[index]['previous_batch_index']
    if previous_batch_index is None:
        return None
    return batches[previous_batch_index]['root_after']