'Get a join for this component
@param implicit: return a subquery with an implicit join rather
than an explicit join
@param reverse: get the reverse join (joining master to component)
@return: a Query if implicit=True, otherwise a list of joins'

def _join(self, implicit=False, reverse=False):

    if (self.parent is None):
        return None
    else:
        ltable = self.parent.table
    rtable = self.table
    pkey = self.pkey
    fkey = self.fkey
    DELETED = current.xml.DELETED
    if self.linked:
        return self.linked._join(implicit=implicit, reverse=reverse)
    elif self.linktable:
        linktable = self.linktable
        lkey = self.lkey
        rkey = self.rkey
        lquery = (ltable[pkey] == linktable[lkey])
        if (DELETED in linktable):
            lquery &= (linktable[DELETED] != True)
        if ((self.filter is not None) and (not reverse)):
            rquery = ((linktable[rkey] == rtable[fkey]) & self.filter)
        else:
            rquery = (linktable[rkey] == rtable[fkey])
        if reverse:
            join = [linktable.on(rquery), ltable.on(lquery)]
        else:
            join = [linktable.on(lquery), rtable.on(rquery)]
    else:
        lquery = (ltable[pkey] == rtable[fkey])
        if ((DELETED in rtable) and (not reverse)):
            lquery &= (rtable[DELETED] != True)
        if (self.filter is not None):
            lquery &= self.filter
        if reverse:
            join = [ltable.on(lquery)]
        else:
            join = [rtable.on(lquery)]
    if implicit:
        query = None
        for expression in join:
            if (query is None):
                query = expression.second
            else:
                query &= expression.second
        return query
    else:
        return join
