public static boolean hasFocusableAncestor(
      @Nullable AccessibilityNodeInfoCompat node, @Nullable View view) {
    if (node == null || view == null) {
      return false;
    }

    final ViewParent parentView = ViewCompat.getParentForAccessibility(view);
    if (!(parentView instanceof View)) {
      return false;
    }

    final AccessibilityNodeInfoCompat parentNode = createNodeInfoFromView((View) parentView);
    try {
      if (parentNode == null) {
        return false;
      }

      if (areBoundsIdenticalToWindow(parentNode, (View) parentView)
          && parentNode.getChildCount() > 0) {
        return false;
      }

      if (isAccessibilityFocusable(parentNode, (View) parentView)) {
        return true;
      }

      if (hasFocusableAncestor(parentNode, (View) parentView)) {
        return true;
      }
    } finally {
      if (parentNode != null) {
        parentNode.recycle();
      }
    }
    return false;
  }
Determines if any of the provided {@link View}'s and {@link AccessibilityNodeInfoCompat}'s
ancestors can receive accessibility focus

@param view The {@link View} to evaluate
@param node The {@link AccessibilityNodeInfoCompat} to evaluate
@return {@code true} if an ancestor of may receive accessibility focus
core/src/main/java/com/facebook/testing/screenshot/layouthierarchy/AccessibilityUtil.java