def _find_leaves(classes):
    """Find leaves of the inheritance hierarchy (classes without subclasses)."""
    leaf_names = set()
    for clazz in classes:
        leaf_names.add(clazz.fullname())
        if clazz.base is not None:
            if clazz.base in leaf_names:
                leaf_names.remove(clazz.base)
    return leaf_names