#vulnerable code 
                                public Document normalise() {
        if (select("html").isEmpty())
            appendElement("html");
        if (head() == null)
            select("html").first().prependElement("head");
        if (body() == null)
            select("html").first().appendElement("body");

        normalise(this);
        normalise(select("html").first());
        normalise(head());

        return this;
    } 
                            #location 10 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public Document normalise() {
        if (select("html").isEmpty())
            appendElement("html");
        if (head() == null)
            select("html").first().prependElement("head");
        if (body() == null)
            select("html").first().appendElement("body");

        // pull text nodes out of root, html, and head els, and push into body. non-text nodes are already taken care
        // of. do in inverse order to maintain text order.
        normalise(head());
        normalise(select("html").first());
        normalise(this);        

        return this;
    }