code: private static boolean isMatchingEdgeListItem(Context context,
              AccessibilityNodeInfoCompat cursor, int direction, NodeFilter filter) {
          AccessibilityNodeInfoCompat ancestor = null;
          AccessibilityNodeInfoCompat searched = null;
          AccessibilityNodeInfoCompat searchedAncestor = null;
  
          try {
              ancestor = getMatchingAncestor(null, cursor, filter);
              if (ancestor == null) {
                  // Not contained in a scrollable list.
                  return false;
              }
  
              // Search in the specified direction until we find a focusable node.
              // TODO: This happens elsewhere -- make into a single utility method.
              searched = NodeFocusFinder.focusSearch(cursor, direction);
              while ((searched != null)
                      && !AccessibilityNodeInfoUtils.shouldFocusNode(context, searched)) {
                  final AccessibilityNodeInfoCompat temp = searched;
                  searched = NodeFocusFinder.focusSearch(temp, direction);
                  temp.recycle();
              }
  
              if ((searched == null) || searched.equals(ancestor)) {
                  // Can't move from this position.
                  return true;
              }
  
              searchedAncestor = getMatchingAncestor(null, searched, filter);
              if (!ancestor.equals(searchedAncestor)) {
                  // Moves outside of the scrollable list.
                  return true;
              }
          } finally {
              recycleNodes(ancestor, searched, searchedAncestor);
          }
  
          return false;
      }
docs: Utility method for determining if a searching past a particular node will
  fall off the edge of a scrollable container.
  
  @param cursor Node to check.
  @param direction The direction in which to move from the cursor.
  @param filter Filter used to validate list-type ancestors.
  @return {@code true} if focusing search in the specified direction will
  fall off the edge of the container.