Program: 23365
Project: 23365
Buggy source:
private void generateByProfile(ResourceWrapper res,StructureDefinition profile,BaseWrapper e,List<ElementDefinition> allElements,ElementDefinition defn,List<ElementDefinition> children,XhtmlNode x,String path,boolean showCodeDetails) throws FHIRException, UnsupportedEncodingException, IOException {
  if (children.isEmpty()) {
    renderLeaf(res,e,defn,x,false,showCodeDetails,readDisplayHints(defn),path);
  }
 else {
    for (    PropertyWrapper p : splitExtensions(profile,e.children())) {
      if (p.hasValues()) {
        ElementDefinition child=getElementDefinition(children,path + "String_Node_Str" + p.getName(),p);
        if (child != null) {
          Map<String,String> displayHints=readDisplayHints(child);
          if (!exemptFromRendering(child)) {
            List<ElementDefinition> grandChildren=getChildrenForPath(allElements,path + "String_Node_Str" + p.getName());
            filterGrandChildren(grandChildren,path + "String_Node_Str" + p.getName(),p);
            if (p.getValues().size() > 0 && child != null) {
              if (isPrimitive(child)) {
                XhtmlNode para=x.addTag("String_Node_Str");
                String name=p.getName();
                if (name.endsWith("String_Node_Str"))                 name=name.substring(0,name.length() - 3);
                if (showCodeDetails || !isDefaultValue(displayHints,p.getValues())) {
                  para.addTag("String_Node_Str").addText(name);
                  para.addText("String_Node_Str");
                  if (renderAsList(child) && p.getValues().size() > 1) {
                    XhtmlNode list=x.addTag("String_Node_Str");
                    for (                    BaseWrapper v : p.getValues())                     renderLeaf(res,v,child,list.addTag("String_Node_Str"),false,showCodeDetails,displayHints,path);
                  }
 else {
                    boolean first=true;
                    for (                    BaseWrapper v : p.getValues()) {
                      if (first)                       first=false;
 else                       para.addText("String_Node_Str");
                      renderLeaf(res,v,child,para,false,showCodeDetails,displayHints,path);
                    }
                  }
                }
              }
 else               if (canDoTable(path,p,grandChildren)) {
                x.addTag("String_Node_Str").addText(Utilities.capitalize(Utilities.camelCase(Utilities.pluralizeMe(p.getName()))));
                XhtmlNode tbl=x.addTag("String_Node_Str").setAttribute("String_Node_Str","String_Node_Str");
                XhtmlNode tr=tbl.addTag("String_Node_Str");
                tr.addTag("String_Node_Str").addText("String_Node_Str");
                addColumnHeadings(tr,grandChildren);
                for (                BaseWrapper v : p.getValues()) {
                  if (v != null) {
                    tr=tbl.addTag("String_Node_Str");
                    tr.addTag("String_Node_Str").addText("String_Node_Str");
                    addColumnValues(res,tr,grandChildren,v,showCodeDetails,displayHints,path);
                  }
                }
              }
 else {
                for (                BaseWrapper v : p.getValues()) {
                  if (v != null) {
                    XhtmlNode bq=x.addTag("String_Node_Str");
                    bq.addTag("String_Node_Str").addTag("String_Node_Str").addText(p.getName());
                    generateByProfile(res,profile,v,allElements,child,grandChildren,bq,path + "String_Node_Str" + p.getName(),showCodeDetails);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void generateByProfile(ResourceWrapper res,StructureDefinition profile,BaseWrapper e,List<ElementDefinition> allElements,ElementDefinition defn,List<ElementDefinition> children,XhtmlNode x,String path,boolean showCodeDetails) throws FHIRException, UnsupportedEncodingException, IOException {
  if (children.isEmpty()) {
    renderLeaf(res,e,defn,x,false,showCodeDetails,readDisplayHints(defn),path);
  }
 else {
    for (    PropertyWrapper p : splitExtensions(profile,e.children())) {
      if (p.hasValues()) {
        ElementDefinition child=getElementDefinition(children,path + "String_Node_Str" + p.getName(),p);
        if (child != null) {
          Map<String,String> displayHints=readDisplayHints(child);
          if (!exemptFromRendering(child)) {
            List<ElementDefinition> grandChildren=getChildrenForPath(allElements,path + "String_Node_Str" + p.getName());
            filterGrandChildren(grandChildren,path + "String_Node_Str" + p.getName(),p);
            if (p.getValues().size() > 0 && child != null) {
              if (isPrimitive(child)) {
                XhtmlNode para=x.addTag("String_Node_Str");
                String name=p.getName();
                if (name.endsWith("String_Node_Str"))                 name=name.substring(0,name.length() - 3);
                if (showCodeDetails || !isDefaultValue(displayHints,p.getValues())) {
                  para.addTag("String_Node_Str").addText(name);
                  para.addText("String_Node_Str");
                  if (renderAsList(child) && p.getValues().size() > 1) {
                    XhtmlNode list=x.addTag("String_Node_Str");
                    for (                    BaseWrapper v : p.getValues())                     renderLeaf(res,v,child,list.addTag("String_Node_Str"),false,showCodeDetails,displayHints,path);
                  }
 else {
                    boolean first=true;
                    for (                    BaseWrapper v : p.getValues()) {
                      if (first)                       first=false;
 else                       para.addText("String_Node_Str");
                      renderLeaf(res,v,child,para,false,showCodeDetails,displayHints,path);
                    }
                  }
                }
              }
 else               if (canDoTable(path,p,grandChildren)) {
                x.addTag(getHeader()).addText(Utilities.capitalize(Utilities.camelCase(Utilities.pluralizeMe(p.getName()))));
                XhtmlNode tbl=x.addTag("String_Node_Str").setAttribute("String_Node_Str","String_Node_Str");
                XhtmlNode tr=tbl.addTag("String_Node_Str");
                tr.addTag("String_Node_Str").addText("String_Node_Str");
                addColumnHeadings(tr,grandChildren);
                for (                BaseWrapper v : p.getValues()) {
                  if (v != null) {
                    tr=tbl.addTag("String_Node_Str");
                    tr.addTag("String_Node_Str").addText("String_Node_Str");
                    addColumnValues(res,tr,grandChildren,v,showCodeDetails,displayHints,path);
                  }
                }
              }
 else {
                for (                BaseWrapper v : p.getValues()) {
                  if (v != null) {
                    XhtmlNode bq=x.addTag("String_Node_Str");
                    bq.addTag("String_Node_Str").addTag("String_Node_Str").addText(p.getName());
                    generateByProfile(res,profile,v,allElements,child,grandChildren,bq,path + "String_Node_Str" + p.getName(),showCodeDetails);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}