def METHOD_NAME(self, context):
    if not self.custom_attribute_keys:
        self.log.info("Custom attribute keys are not set. Skipping")
        return
    ftrack_entities_by_id = {}
    default_entity_id = None
    context_entity = context.data.get("ftrackEntity")
    if context_entity:
        entity_id = context_entity["id"]
        default_entity_id = entity_id
        ftrack_entities_by_id[entity_id] = context_entity
    instances_by_entity_id = {
        default_entity_id: []
    }
    for instance in context:
        entity = instance.data.get("ftrackEntity")
        if not entity:
            instances_by_entity_id[default_entity_id].append(instance)
            continue
        entity_id = entity["id"]
        ftrack_entities_by_id[entity_id] = entity
        if entity_id not in instances_by_entity_id:
            instances_by_entity_id[entity_id] = []
        instances_by_entity_id[entity_id].append(instance)
    if not ftrack_entities_by_id:
        self.log.info("Ftrack entities are not set. Skipping")
        return
    session = context.data["ftrackSession"]
    custom_attr_key_by_id = self.query_attr_confs(session)
    if not custom_attr_key_by_id:
        self.log.info((
            "Didn't find any of defined custom attributes {}"
        ).format(", ".join(self.custom_attribute_keys)))
        return
    entity_ids = list(instances_by_entity_id.keys())
    values_by_entity_id = self.query_attr_values(
        session, entity_ids, custom_attr_key_by_id
    )
    for entity_id, instances in instances_by_entity_id.items():
        if entity_id not in values_by_entity_id:
            # Use default empty values
            entity_id = None
        for instance in instances:
            value = copy.deepcopy(values_by_entity_id[entity_id])
            if "customData" not in instance.data:
                instance.data["customData"] = {}
            instance.data["customData"]["ftrack"] = value
            instance_label = (
                instance.data.get("label") or instance.data["name"]
            )
            self.log.debug((
                "Added ftrack custom data to instance \"{}\": {}"
            ).format(instance_label, value))