'Selects the next tabstop or the previous if \'backwards\' is True.'

def select_next_tab(self, backwards=False):

    if (self._cts is None):
        return
    if backwards:
        cts_bf = self._cts
        res = self._get_prev_tab(self._cts)
        if (res is None):
            self._cts = cts_bf
            return self._tabstops.get(self._cts, None)
        (self._cts, ts) = res
        return ts
    else:
        res = self._get_next_tab(self._cts)
        if (res is None):
            self._cts = None
            ts = self._get_tabstop(self, 0)
            if ts:
                return ts
            start = Position(self.end.line, self.end.col)
            end = Position(self.end.line, self.end.col)
            return TabStop(self, 0, start, end)
        else:
            (self._cts, ts) = res
            return ts
    return self._tabstops[self._cts]
