nsCOMPtr<nsIContent> parent; content->GetParent(getter_AddRefs(parent)); content = parent;
content = content->GetParent();
IsElementInBuilder(nsIContent *aContent, nsIXULTemplateBuilder *aBuilder){    // Make sure that the element is contained within the heirarchy    // that we're supposed to be processing.    nsCOMPtr<nsIDocument> doc;    aContent->GetDocument(getter_AddRefs(doc));    nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc);    if (! xuldoc)        return PR_FALSE;    nsCOMPtr<nsIContent> content = aContent;    do {        nsCOMPtr<nsIXULTemplateBuilder> builder;        xuldoc->GetTemplateBuilderFor(content, getter_AddRefs(builder));        if (builder) {            if (builder == aBuilder)                return PR_TRUE; // aBuilder is the builder for this element.            // We found a builder, but it's not aBuilder.            break;        }        nsCOMPtr<nsIContent> parent;        content->GetParent(getter_AddRefs(parent));        content = parent;    } while (content);    return PR_FALSE;}