def METHOD_NAME(ds, lyr, ifield, bAppend, bOverwrite):
    first_table = lyr.GetName()
    second_table = lyr.GetLayerDefn().GetFieldDefn(ifield).GetName()[0:-5]
    junction_table_name = first_table + "_" + second_table
    gdal.PushErrorHandler("CPLQuietErrorHandler")
    junction_lyr = ds.GetLayerByName(junction_table_name)
    gdal.PopErrorHandler()
    if junction_lyr is not None:
        if bOverwrite:
            for i in range(ds.GetLayerCount()):
                if ds.GetLayer(i).GetName() == junction_table_name:
                    if ds.DeleteLayer(i) != 0:
                        print(
                            "Cannot delete layer %s for recreation"
                            % junction_table_name
                        )
                        return False
                    else:
                        junction_lyr = None
                    break
        elif not bAppend:
            print("Layer %s already exists" % junction_table_name)
            return False
    if junction_lyr is None:
        junction_lyr = ds.CreateLayer(junction_table_name, geom_type=ogr.wkbNone)
        if junction_lyr is None:
            print("Cannot create layer %s" % junction_table_name)
            return False
        print("Creating layer %s..." % junction_table_name)
        fld_defn = ogr.FieldDefn(first_table + "_gml_id", ogr.OFTString)
        if junction_lyr.CreateField(fld_defn) != 0:
            print("Cannot create field %s" % fld_defn.GetName())
            return False
        fld_defn = ogr.FieldDefn(second_table + "_gml_id", ogr.OFTString)
        if junction_lyr.CreateField(fld_defn) != 0:
            print("Cannot create field %s" % fld_defn.GetName())
            return False
        gdal.PushErrorHandler("CPLQuietErrorHandler")
        ds.ExecuteSQL(
            "CREATE INDEX idx_%s_gml_id ON %s(gml_id)" % (first_table, first_table)
        )
        ds.ExecuteSQL(
            "CREATE INDEX idx_%s_gml_id ON %s(gml_id)" % (second_table, second_table)
        )
        ds.ExecuteSQL(
            "CREATE INDEX idx_%s_gml_id ON %s(%s)"
            % (
                junction_table_name + "_" + first_table,
                junction_table_name,
                first_table + "_gml_id",
            )
        )
        ds.ExecuteSQL(
            "CREATE INDEX idx_%s_gml_id ON %s(%s)"
            % (
                junction_table_name + "_" + second_table,
                junction_table_name,
                second_table + "_gml_id",
            )
        )
        gdal.PopErrorHandler()
    lyr.ResetReading()
    field_type = lyr.GetLayerDefn().GetFieldDefn(ifield).GetType()
    junction_lyr.StartTransaction()
    count_features = 0
    for feat in lyr:
        gml_id = feat.GetFieldAsString("gml_id")
        if field_type == ogr.OFTStringList:
            href_list = feat.GetFieldAsStringList(ifield)
        else:
            href = feat.GetFieldAsString(ifield)
            if href[0] == "(" and href.find(":") > 0 and href[-1] == ")":
                href_list = href[href.find(":") + 1 : -1].split(",")
            else:
                href_list = [href]
        for href in href_list:
            target_feature = ogr.Feature(junction_lyr.GetLayerDefn())
            target_feature.SetField(0, gml_id)
            if href[0] == "#":
                href = href[1:]
            target_feature.SetField(1, href)
            junction_lyr.CreateFeature(target_feature)
            target_feature = None
            count_features = count_features + 1
            if count_features == 200:
                junction_lyr.CommitTransaction()
                junction_lyr.StartTransaction()
                count_features = 0
    junction_lyr.CommitTransaction()
    return True