{ ReteNodeSet::Iterator last = livenodes.Last(); for (ReteNodeSet::Iterator i = livenodes.First(); i != last; ++i) { nsRDFTestNode* rdftestnode = NS_STATIC_CAST(nsRDFTestNode*, *i);  PRBool isdominated = PR_FALSE;  for (ReteNodeSet::ConstIterator j = livenodes.First(); j != last; ++j) {  if (j == i) continue;  if (rdftestnode->HasAncestor(*j)) { isdominated = PR_TRUE; break; } }  if (! isdominated) {  Instantiation seed; rdftestnode->CanPropogate(aSource, aProperty, aTarget, seed);  InstantiationSet instantiations; instantiations.Append(seed);  rv = rdftestnode->Constrain(instantiations, &mConflictSet); if (NS_FAILED(rv)) return rv;  if (! instantiations.Empty()) { rv = rdftestnode->Propogate(instantiations, &aNewKeys); if (NS_FAILED(rv)) return rv; } } } }
nsXULTemplateBuilder::Propogate(nsIRDFResource* aSource,                                nsIRDFResource* aProperty,                                nsIRDFNode* aTarget,                                nsClusterKeySet& aNewKeys){    // Find the "dominating" tests that could be used to propogate the    // assertion we've just received. (Test A "dominates" test B if A    // is an ancestor of B in the rule network).    nsresult rv;    // First, we'll go through and find all of the test nodes that can    // propogate the assertion.    ReteNodeSet livenodes;    {        ReteNodeSet::Iterator last = mRDFTests.Last();        for (ReteNodeSet::Iterator i = mRDFTests.First(); i != last; ++i) {            nsRDFTestNode* rdftestnode = NS_STATIC_CAST(nsRDFTestNode*, *i);            Instantiation seed;            if (rdftestnode->CanPropogate(aSource, aProperty, aTarget, seed)) {                livenodes.Add(rdftestnode);            }        }    }    // Now, we'll go through each, and any that aren't dominated by    // another live node will be used to propogate the assertion    // through the rule network    {        ReteNodeSet::Iterator last = livenodes.Last();        for (ReteNodeSet::Iterator i = livenodes.First(); i != last; ++i) {            nsRDFTestNode* rdftestnode = NS_STATIC_CAST(nsRDFTestNode*, *i);            PRBool isdominated = PR_FALSE;            for (ReteNodeSet::ConstIterator j = livenodes.First(); j != last; ++j) {                // we can't be dominated by ourself                if (j == i)                    continue;                if (rdftestnode->HasAncestor(*j)) {                    isdominated = PR_TRUE;                    break;                }            }            if (! isdominated) {                // Bogus, to get the seed instantiation                Instantiation seed;                rdftestnode->CanPropogate(aSource, aProperty, aTarget, seed);                InstantiationSet instantiations;                instantiations.Append(seed);                rv = rdftestnode->Constrain(instantiations, &mConflictSet);                if (NS_FAILED(rv)) return rv;                if (! instantiations.Empty()) {                    rv = rdftestnode->Propogate(instantiations, &aNewKeys);                    if (NS_FAILED(rv)) return rv;                }            }        }    }    return NS_OK;}