code: def _recursive_find_mcm_stats_layer(
      layer_to_check, op_occupied_cwires, used_cwires_per_layer, bit_map
  ):
      """Determine correct layer for a terminal measurement that is collectings statistics
      for mid-circuit measurement values.
  
      Args:
          layer_to_check (int): the function determines if the operation fits on this layer
          op_occupied_cwires (set(int)): classical wires occupied by measurement
          occupied_cwires_per_layer (list[set[int]]): which classical wires are already
              in use for collecting statistics. Each set is a different layer.
          bit_map (dict): A map containing mid-circuit measurements used for classical conditions
              or collecting statistics as keys
  
      Returns:
          int: layer to place measurement process in
      """
  
      if op_occupied_cwires & used_cwires_per_layer[layer_to_check]:
          # this layer is occupied, use higher one
          return layer_to_check + 1
  
      if layer_to_check == 0:
          # reached first layer, so stop
          return 0
      # keep pushing the operation to lower layers
      return _recursive_find_mcm_stats_layer(
          layer_to_check - 1,
          op_occupied_cwires,
          used_cwires_per_layer,
          bit_map,
      )
  
imports: from pennylane.ops import Conditional
  from pennylane.measurements import MidMeasureMP, MeasurementProcess
  from .utils import default_wire_map
label_desc: Use image node_id 2 for calling a global function with example usage: _recursive_find_mcm_stats_layer(layer_to_check, op_occupied_cwires, used_cwires_per_layer, bit_map) and returns: _recursive_find_mcm_stats_layer, unknown, int