':return: a set of all the lists of children that cover ``span``
and that match ``rhs``.
:rtype: list(list(ProbabilisticTree or token)
:type rhs: list(Nonterminal or any)
:param rhs: The list specifying what kinds of children need to
cover ``span``.  Each nonterminal in ``rhs`` specifies
that the corresponding child should be a tree whose node
value is that nonterminal\'s symbol.  Each terminal in ``rhs``
specifies that the corresponding child should be a token
whose type is that terminal.
:type span: tuple(int, int)
:param span: The section of the text for which we are
trying to find child lists.  The span is specified as a
pair of integers, where the first integer is the index of
the first token that should be covered by the child list;
and the second integer is the index of the first token
that should not be covered by the child list.
:type constituents: dict(tuple(int,int,Nonterminal) -> ProbabilisticToken or ProbabilisticTree)
:param constituents: The most likely constituents table.  This
table records the most probable tree representation for
any given span and node value.  See the module
documentation for more information.'

def _match_rhs(self, rhs, span, constituents):

    (start, end) = span
    if ((start >= end) and (rhs == ())):
        return [[]]
    if ((start >= end) or (rhs == ())):
        return []
    childlists = []
    for split in range(start, (end + 1)):
        l = constituents.get((start, split, rhs[0]))
        if (l is not None):
            rights = self._match_rhs(rhs[1:], (split, end), constituents)
            childlists += [([l] + r) for r in rights]
    return childlists
