···3838 body2::binary,
3939 >> = body
40404141- <<
4242- key_size::integer-16,
4343- _value_size::integer-16,
4444- end_key1::binary-size(key_size),
4545- _rest::binary,
4646- >> = body2
4141+ end_key1 =
4242+ case type_byte do
4343+ 0x00 ->
4444+ # For an inner page, the end_key is equal to the last key in the page (which is itself the end_key of the child page)
4545+ offset = List.last(offsets1)
4646+ <<_::binary-size(offset), key_size::integer-16, _vs::integer-16, end_key1::binary-size(key_size), _::binary>> = body1
4747+ end_key1
4848+ 0x01 ->
4949+ # For a leaf page, the end_key is an exclusive separator key, so we choose the first key of the next page
5050+ <<key_size::integer-16, _vs::integer-16, end_key1::binary-size(key_size), _::binary>> = body2
5151+ end_key1
5252+ end
4753 end_key2 = end_key
48544955 pair_count1 = midpoint_i