private static @Nullable WeakReference<Component> validateFosterParent(@NotNull Component component, @Nullable Component parent) {
    if (parent != null && isGeneralizedAncestor(component, parent)) {
      throw new IllegalArgumentException("Setting this component as a foster parent will form a cycle in a hierarchy graph");
    }
    return parent != null ? new WeakReference<>(parent) : null;
  }
private static @Nullable WeakReference<Component> validateFosterParent(@NotNull Component component, @Nullable Component parent)