code: public static AccessibilityNodeInfoCompat searchFromInOrderTraversal(
              Context context, AccessibilityNodeInfoCompat root, NodeFilter filter, int direction) {
          AccessibilityNodeInfoCompat currentNode = NodeFocusFinder.focusSearch(root, direction);
  
          final HashSet<AccessibilityNodeInfoCompat> seenNodes =
                  new HashSet<AccessibilityNodeInfoCompat>();
  
          while ((currentNode != null) && !seenNodes.contains(currentNode)
                  && !filter.accept(context, currentNode)) {
              seenNodes.add(currentNode);
              currentNode = NodeFocusFinder.focusSearch(currentNode, direction);
          }
  
          // Recycle all the seen nodes.
          AccessibilityNodeInfoUtils.recycleNodes(seenNodes);
  
          return currentNode;
      }
docs: Performs in-order traversal from a given node in a particular direction
  until a node matching the specified filter is reached.
  
  @param context The parent context.
  @param root The root node to traverse from.
  @param filter The filter to satisfy.
  @return The first node reached via in-order traversal that satisfies the
  filter.