def get_leaves()

in videocategorization/create_prompts.py [0:0]


def get_leaves(taxonomy):
    leaves = []
    for key, value in taxonomy.items():
        if isinstance(value, dict) and value:  # If it's a non-empty dictionary
            leaves.extend(get_leaves(value))
        else:  # If it's an empty dictionary, consider it as a leaf
            if not value:  # Check if the value is an empty dictionary
                leaves.append(key)
    return leaves