Well, this is unfortunate: $ python3 test.py b'\xacL\t\xc2\x06\xe7\xe34/]\n^HBx\xc3\xa9g\xb3g\x11\xeb\x87\xbd\xc1\xf7z\x7f\x86X\x95C\xe4v(3\x81\x86&Hb|\xc1M\x9e\xc3\x04\xbd\xfc\xe8\xd4eO\xd6\xba\x1a\xe6WX\xdexO\x8f\x92ZUD\xf2P\x16c\x9c\xc1\x83s\xf7\x13ZTq\x9e\xf3\x84\xdd\x02\x8e\xf1\x0f\xce\x17\x16+\xd3\xb5\n)\xd3\x9cz\xf4\xfb\xd3*7\x1b\xdej\xf1p>\xf3\xba' [(9, 9, 0, 45), (9, 18, 45, 39), (3, 21, 84, 13), (1, 22, 97, 1), (1, 23, 98, 8), (-1, b'j\xf1p>\xf3\xba', 106, 6)] Traceback (most recent call last): File "/shared/src/flat_tree/test.py", line 43, in <module> cmp = b''.join(iterate(index, 0, index.byte_count)) File "/shared/src/flat_tree/test.py", line 30, in iterate data = b''.join(iterate(subindex, adjusted_start, min(adjusted_end, subsize - adjusted_start))) File "/shared/src/flat_tree/test.py", line 34, in iterate assert len(data) == subleafcount AssertionError