'Returns the token that is on position offset.'

def get_token_at_offset(self, offset):

    idx = 0
    for token in self.flatten():
        end = (idx + len(token.value))
        if (idx <= offset < end):
            return token
        idx = end
