'Helper method to ensure consistent prefixing of field selectors
@param selector: the selector'

def prefix_selector(self, selector):

    head = selector.split('$', 1)[0]
    if ('.' in head):
        prefix = head.split('.', 1)[0]
        if (prefix == self.alias):
            return selector.replace(('%s.' % prefix), '~.')
        else:
            return selector
    else:
        return ('~.%s' % selector)
