pub fn check_hierarchy_component_has_valid_parent<T>(
    parent_query: Query<'_, '_, (Entity, &Parent, Option<&Name>), (With<T>, Or<(Changed<Parent>, Added<T>)>)>,
    component_query: Query<'_, '_, (), With<T>>,
    already_diagnosed: Local<'_, HashSet<Entity>>
)
where T: Component,
Expand description

System to print a warning for each Entity with a T component which parent hasn’t a T component.

Hierarchy propagations are top-down, and limited only to entities with a specific component (such as InheritedVisibility and GlobalTransform). This means that entities with one of those component and a parent without the same component is probably a programming error. (See B0004 explanation linked in warning message)