@Nullable
  private static AccessibilityNodeInfoCompat createNodeInfoFromView(
      @Nullable View view, int retryCount) {
    if (view == null) {
      return null;
    }

    final AccessibilityNodeInfoCompat nodeInfo = AccessibilityNodeInfoCompat.obtain();

    // For some unknown reason, Android seems to occasionally throw a NPE from
    // onInitializeAccessibilityNodeInfo.
    try {
      ViewCompat.onInitializeAccessibilityNodeInfo(view, nodeInfo);
    } catch (NullPointerException e) {
      if (nodeInfo != null) {
        nodeInfo.recycle();
      }
      return null;
    } catch (RuntimeException e) {
      if (nodeInfo != null) {
        nodeInfo.recycle();
      }
      // For some unknown reason, Android seems to occasionally throw a IndexOutOfBoundsException
      // and also random RuntimeExceptions because the handler seems not to be initialized
      // from onInitializeAccessibilityNodeInfoInternal in ViewGroup.  This seems to be
      // nondeterministic, so lets retry if this happens.
      if (retryCount > 0) {
        return createNodeInfoFromView(view, retryCount - 1);
      }

      return null;
    }

    return nodeInfo;
  }
Creates and returns an {@link AccessibilityNodeInfoCompat} from the the provided {@link View}.
Note: This does not handle recycling of the {@link AccessibilityNodeInfoCompat}.

@param view The {@link View} to create the {@link AccessibilityNodeInfoCompat} from.
@param retryCount The number of times to retry creating the AccessibilityNodeInfoCompat.
@return {@link AccessibilityNodeInfoCompat}
core/src/main/java/com/facebook/testing/screenshot/layouthierarchy/AccessibilityUtil.java