def _loc(self, pos, idx):
if not pos:<EOL><INDENT>return idx<EOL><DEDENT>_index = self._index<EOL>if not _index:<EOL><INDENT>self._build_index()<EOL><DEDENT>total = <NUM_LIT:0><EOL>pos += self._offset<EOL>while pos:<EOL><INDENT>if not pos & <NUM_LIT:1>:<EOL><INDENT>total += _index[pos - <NUM_LIT:1>]<EOL><DEDENT>pos = (pos - <NUM_LIT:1>) >> <NUM_LIT:1><EOL><DEDENT>return total + idx<EOL>
Convert an index pair (alpha, beta) into a single index that corresponds to
        the position of the value in the sorted list.

        Most queries require the index be built. Details of the index are
        described in self._build_index.

        Indexing requires traversing the tree from a leaf node to the root. The
        parent of each node is easily computable at (pos - 1) // 2.

        Left-child nodes are always at odd indices and right-child nodes are
        always at even indices.

        When traversing up from a right-child node, increment the total by the
        left-child node.

        The final index is the sum from traversal and the index in the sublist.

        For example, using the index from self._build_index:

        _index = 14 5 9 3 2 4 5
        _offset = 3

        Tree:

                 14
              5      9
            3   2  4   5

        Converting index pair (2, 3) into a single index involves iterating like
        so:

        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify
           the node as a left-child node. At such nodes, we simply traverse to
           the parent.

        2. At node 9, position 2, we recognize the node as a right-child node
           and accumulate the left-child in our total. Total is now 5 and we
           traverse to the parent at position 0.

        3. Iteration ends at the root.

        Computing the index is the sum of the total and beta: 5 + 3 = 8.