public static boolean hasVisibleChildren(View view) {
    if (!(view instanceof ViewGroup)) {
      return false;
    }

    ViewGroup viewGroup = (ViewGroup) view;
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; ++i) {
      AccessibilityNodeInfoCompat childNodeInfo = createNodeInfoFromView(viewGroup.getChildAt(i));
      if (childNodeInfo != null) {
        try {
          if (childNodeInfo.isVisibleToUser()) {
            return true;
          }
        } finally {
          childNodeInfo.recycle();
        }
      }
    }

    return false;
  }
Returns whether a View has any children that are visible.

@param view The {@link View} to evaluate
@return {@code true} if node has any visible children
core/src/main/java/com/facebook/testing/screenshot/layouthierarchy/AccessibilityUtil.java