<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _create_barrier_entities(root_pipeline_key, child_pipeline_key, purpose, blocking_slot_keys):
 """Creates all of the entities required for a _BarrierRecord. Args: root_pipeline_key: The root pipeline this is part of. child_pipeline_key: The pipeline this barrier is for. purpose: _BarrierRecord.START or _BarrierRecord.FINALIZE. blocking_slot_keys: Set of db.Keys corresponding to _SlotRecords that this barrier should wait on before firing. Returns: List of entities, starting with the _BarrierRecord entity, followed by _BarrierIndexes used for firing when _SlotRecords are filled in the same order as the blocking_slot_keys list provided. All of these entities should be put in the Datastore to ensure the barrier fires properly. """

    result = []

    blocking_slot_keys = list(blocking_slot_keys)

    barrier = _BarrierRecord(
        parent=child_pipeline_key,
        key_name=purpose,
        target=child_pipeline_key,
        root_pipeline=root_pipeline_key,
        blocking_slots=blocking_slot_keys)

    result.append(barrier)

    for slot_key in blocking_slot_keys:
      barrier_index_path = []
      barrier_index_path.extend(slot_key.to_path())
      barrier_index_path.extend(child_pipeline_key.to_path())
      barrier_index_path.extend([_BarrierIndex.kind(), purpose])
      barrier_index_key = db.Key.from_path(*barrier_index_path)
      barrier_index = _BarrierIndex(
          key=barrier_index_key,
          root_pipeline=root_pipeline_key)
      result.append(barrier_index)

    return result