def METHOD_NAME(domain, locations, metadata=None):
    """
    Creates a hierarchy of locations given a recursive list of LocationStructure namedtuples
    This allows you to set complex (e.g. forked) location structures within tests
    """
    created_locations = {}
    def create_locations(locations, parent, metadata):
        for location in locations:
            created_location = make_location(domain=domain, name=location.name, parent=parent,
                                             location_type=location.type)
            if metadata:
                created_location.metadata = metadata
            created_location.save()
            created_locations[location.name] = created_location.sql_location
            create_locations(location.children, created_location, metadata)
    create_locations(locations, None, metadata)
    return created_locations