function findDOMText(root, content, asLink) {
        // Unfortunately, we can't just use jQuery's :contains() selector, because it appears that
        // you can't escape quotes in it.
        var i;
        if (root.jquery) {
            root = root.get(0);
        }
        if (!root) {
            return false;
        } else if (!asLink && root.nodeType === 3) { // text node
            return root.textContent.indexOf(content) !== -1;
        } else {
            if (asLink && root.nodeType === 1 && root.tagName.toLowerCase() === "a" && root.getAttribute("href") === content) {
                return true;
            }
            var children = root.childNodes;
            for (i = 0; i < children.length; i++) {
                if (findDOMText(children[i], content, asLink)) {
                    return true;
                }
            }
            return false;
        }
    }
Searches the DOM tree for text containing the given content. Useful for verifying
that data you expect to show up in the UI somewhere is actually there.

@param {jQueryObject|Node} root The root element to search from. Can be either a jQuery object
    or a raw DOM node.
@param {string} content The content to find.
@param {boolean} asLink If true, find the content in the href of an <a> tag, otherwise find it in text nodes.
@return true if content was found