navigation/runtime/src/main/java/androidx/navigation/Navigation.java
@Nullable
    private static NavController findViewNavController(@NonNull View view) {
        while (view != null) {
            NavController controller = getViewNavController(view);
            if (controller != null) {
                return controller;
            }
            ViewParent parent = view.getParent();
            view = parent instanceof View ? (View) parent : null;
        }
        return null;
    }
/**
     * Recurse up the view hierarchy, looking for the NavController
     * @param view the view to search from
     * @return the locally scoped {@link NavController} to the given view, if found
     */
Recurse up the view hierarchy, looking for the NavController
@param view the view to search from
@return the locally scoped  NavController to the given view, if found
Recurse up the view hierarchy looking for the NavController @param view the view to search from @return the locally scoped NavController to the given view if found
@Nullable
    private static NavController findViewNavController(@NonNull View view) {
        while (view != null) {
            NavController controller = getViewNavController(view);
            if (controller != null) {
                return controller;
            }
            ViewParent parent = view.getParent();
            view = parent instanceof View ? (View) parent : null;
        }
        return null;
    }
@ Nullable private static NavController findViewNavController ( @ NonNull View view ) { while ( view != null ) { NavController controller = getViewNavController ( view ) ; if ( controller != null ) { return controller ; } ViewParent parent = view . getParent ( ) ; view = parent instanceof View ? ( View ) parent : null ; } return null ; }
Recurse up the view hierarchy, looking for the NavController
 @param view the view to search from
 @return the locally scoped {@link NavController} to the given view, if found
Recurse up the view hierarchy looking for the NavController @param view the view to search from @return the locally scoped { @link NavController } to the given view if found