/// <summary> /// Checks if hierarchy item is equal to reference item or its child (disregarding of level). /// </summary> /// <param name="source"> Source item. </param> /// <param name="reference"> Reference item. </param> /// <returns> Value indicates if source is equal to reference or reference is child of source. </returns> public static bool IsEqualOrChildOf(this IHierarchy source, IHierarchy reference) { return(source.Equals(reference) || reference.Children.Any(source.IsEqualOrChildOf)); }