def disjoint_relations(rdf, fix=False):
    """Check if the graph contains concepts connected by both of the semantically
    disjoint semantic skos:related and skos:broaderTransitive (S27),
    and optionally remove the involved skos:related relations.

    :param Graph rdf: An rdflib.graph.Graph object.
    :param bool fix: Fix the problem by removing skos:related relations that
        overlap with skos:broaderTransitive.
    """
    for conc1, conc2 in sorted(rdf.subject_objects(SKOS.related)):
        if conc2 in sorted(rdf.transitive_objects(conc1, SKOS.broader)):
            if fix:
                logging.warning(
                    "Concepts %s and %s connected by both "
                    "skos:broaderTransitive and skos:related, "
                    "removing skos:related",
                    conc1, conc2)
                rdf.remove((conc1, SKOS.related, conc2))
                rdf.remove((conc2, SKOS.related, conc1))
            else:
                logging.warning(
                    "Concepts %s and %s connected by both "
                    "skos:broaderTransitive and skos:related, "
                    "but keeping it because keep_related is enabled",
                    conc1, conc2)