def METHOD_NAME(g, fn, subj, cls):
    g.add((subj, RDF.type, cls))
    fn_parts = list(map(rdflib.Literal, fn.replace("\\", "/")[len(base_path)+1:].split("/")))[::-1]
    c = Collection(g, fqdn(f"doc_{i}_filename"), fn_parts)
    g.add((subj, fqdn("hasFilename"), c.uri))
    def write(s, ct):
        heading = ct.heading.strip()
        m = re.search(r"\[([\w\- ]+)\]", heading)
        if m:
            mvd = m.group(1)
            g.add((s, fqdn("hasContext"), rdflib.Literal(mvd)))
            li = [c for c in heading]
            li[slice(*m.span())] = []
            heading = (mvd, "".join(li).strip())
        g.add((s, fqdn("hasCleanHeading"), rdflib.Literal(heading)))
        g.add((s, fqdn("hasHeading"), rdflib.Literal(ct.heading)))
        if ct.content.strip():
            g.add((s, fqdn("hasText"), rdflib.Literal(ct.content)))
        for i, ch in enumerate(ct.children):
            s2 = s + f"_{i}"
            g.add((s2, fqdn("containedIn"), s))
            write(s2, ch)
    contents = parse_document(fn=fn)
    if contents:
        write(subj, contents)