An internal node routes a search to exactly one child. Today you write that choice - given the separator keys, pick which child page to follow - pinning the rule that a key equal to a separator goes right.
Given an internal node's separator keys, return the index of the child to descend into for a target key.
Search through the tree is a sequence of these choices: at each internal node, the
separator keys split the key space into ranges, and the target key falls into
exactly one. The rule is that separator Keys[i] is the smallest key in child
i + 1’s subtree, so a key equal to a separator belongs in the right child,
not the left. That “equal goes right” convention has to match the leaf split from
last lesson, where the separator was the right leaf’s first key.
Concretely, you follow child i where i is the number of separators less than or
equal to the target - the first child whose upper bound the target does not reach.
With keys [20, 40] there are three children covering “below 20”, “20 up to 40”,
and “40 and above.” Getting the equality boundary right is what keeps a key
findable after its leaf has been split away into the right sibling.
// follow child i, where i is the count of separators <= target,// i.e. the first index whose key is strictly greater than target.func childIndex(keys []uint64, target uint64) int {i := 0// while i < len(keys) && keys[i] <= target { i++ }return i}