def _randbelow(self, n, bpf=BPF, maxwidth=1L<<BPF,
                   long=long, _log=_log, int=int):

        # k is a sometimes over but never under estimate of the bits in n
        k = int(1.00001 + _log(n-1, 2))     # 2**k > n-1 >= 2**(k-2)

        random = self.random
        r = n
        while r >= n:
            # In Py2.4, this section becomes:  r = self.getrandbits(k)
            r = long(random() * maxwidth)
            bits = bpf
            while bits < k:
                r = (r << bpf) | (long(random() * maxwidth))
                bits += bpf
            r >>= (bits - k)
        return r

## -------------------- sequence methods  -------------------
Add the given suffix in the tree: uses __search() and __insert()
dataset/ETHPy150Open babble/babble/include/jython/Lib/random.py/Random._randbelow--crossover with--dataset/ETHPy150Open sfu-natlang/Kriya/src/Kriya-Grammar-Xtrctr/myTrie1.py/SuffixTreeNode.addSuffix