def determinize_tree(determinization, ppddl_tree, index = 0):
  """
  Replaces all probabilistic effects with the given determinization.
  
  Variable "determinization" is a list of determinizations, as created by 
  "get_all_determinizations_effect". 
  
  This function will visit the PPDDL tree in pre-order traversal and each time 
  it encounters a probabilistic effect, it will replace it with the effect at 
  "determinizaton[index][1][1]", then increment variable "index" and return its 
  new value. 
  
  Therefore, the user of this function must ensure that the each effect in 
  the given determinization corresponds to the proper probabilistic effect 
  in the PPDDL tree.
  """
  if not isinstance(ppddl_tree, list) or not ppddl_tree:
    return index
  if ppddl_tree[0] == 'probabilistic':
    ppddl_tree[:] = []
    ppddl_tree.extend(determinization[index][1][1])
    return index + 1
  else:
    for element in ppddl_tree:
      index = determinize_tree(determinization, element, index)
  return index