'Return index or None for a given location.'

def index_for_location(self, location):

    if (location == u'_begin'):
        i = 0
    elif (location == u'_end'):
        i = None
    elif (location.startswith(u'<') or location.startswith(u'>')):
        i = self.index(location[1:])
        if location.startswith(u'>'):
            if (i >= len(self)):
                i = None
            else:
                i += 1
    else:
        raise ValueError((u'Not    a    valid    location:    "%s".    Location    key    must    start    with    a    ">"    or    "<".' % location))
    return i
