code: public static boolean isEdgeListItem(
              Context context, AccessibilityNodeInfoCompat node, int direction, NodeFilter filter) {
          if (node == null) {
              return false;
          }
  
          if ((direction <= 0) && isMatchingEdgeListItem(context, node,
                  NodeFocusFinder.SEARCH_BACKWARD, FILTER_SCROLL_BACKWARD.and(filter))) {
              return true;
          }
  
          if ((direction >= 0) && isMatchingEdgeListItem(context, node,
                  NodeFocusFinder.SEARCH_FORWARD, FILTER_SCROLL_FORWARD.and(filter))) {
              return true;
          }
  
          return false;
      }
docs: Determines if the current item is at the edge of a list by checking the
  scrollable predecessors of the items on either or both sides.
  
  @param context The parent context.
  @param node The node to check.
  @param direction The direction in which to check, one of:
  <ul>
  <li>{@code -1} to check backward
  <li>{@code 0} to check both backward and forward
  <li>{@code 1} to check forward
  </ul>
  @param filter (Optional) Filter used to validate list-type ancestors.
  @return true if the current item is at the edge of a list.