def METHOD_NAME(self, item_id, raw_data):
    nb_deps = 1
    if item_id not in raw_data:
        return 0
    existing_item = self.cache_index.get(item_id)
    if existing_item is not None:
        return existing_item["nb_deps"]
    # Recursive enlist for every refs
    item = raw_data[item_id]
    for key in list(item.keys()):
        value = item[key]
        if key.endswith("_refs") and self.is_ref_key_supported(key):
            to_keep = []
            for element_ref in item[key]:
                if element_ref != item_id:
                    nb_deps += self.METHOD_NAME(element_ref, raw_data)
                    to_keep.append(element_ref)
                item[key] = to_keep
        elif key.endswith("_ref") and self.is_ref_key_supported(key):
            if item[key] == item_id:
                item[key] = None
            else:
                # Need to handle the special case of recursive ref for created by ref
                is_created_by_ref = key == "created_by_ref"
                if is_created_by_ref:
                    is_marking = item["id"].startswith("marking-definition--")
                    if is_marking is False:
                        nb_deps += self.METHOD_NAME(value, raw_data)
                else:
                    nb_deps += self.METHOD_NAME(value, raw_data)
    # Get the final dep counting and add in cache
    item["nb_deps"] = nb_deps
    self.elements.append(item)
    self.cache_index[item_id] = item  # Put in cache
    return nb_deps