Don't you need (up to) `N cut depths - 1` keys per pin? E.g. if there are 4 possible cut depths for a pin, and your key has depth 3 on pin 1, you need to (potentially) test depths 1, 2, and 4 -- and if none of them work, your key shares a depth with the master key.