[sdk] Fix incorrect assumptions in the AVL binary search routines