let remove_min (heap: heap) : data = 
    if heap.hp_length <= 0 then begin
      raise Not_found
    end;

    let data =
      heap.hp_heap.(0)
    in
      heap.hp_length <- heap.hp_length - 1;
      
      if heap.hp_length > 0 then begin
        sift_down heap heap.hp_heap.(heap.hp_length) 0
      end;

      heap.hp_heap.(heap.hp_length) <- heap.hp_null_element;

      check heap;

      data