internal static Focusable GetNextFocusableInTree(VisualElement currentFocusable)
        {
            if (currentFocusable == null)
            {
                return(null);
            }

            VisualElement ve = currentFocusable.GetNextElementDepthFirst();

            while (!ve.canGrabFocus || ve.tabIndex < 0 || ve.excludeFromFocusRing)
            {
                ve = ve.GetNextElementDepthFirst();

                if (ve == null)
                {
                    // continue at the beginning
                    ve = currentFocusable.GetRoot();
                }

                if (ve == currentFocusable)
                {
                    // We went through the whole tree and did not find anything.
                    return(currentFocusable);
                }
            }

            return(ve);
        }
        internal static Focusable GetNextFocusableInTree(VisualElement currentFocusable)
        {
            bool      flag = currentFocusable == null;
            Focusable result;

            if (flag)
            {
                result = null;
            }
            else
            {
                VisualElement nextElementDepthFirst = currentFocusable.GetNextElementDepthFirst();
                while (!nextElementDepthFirst.canGrabFocus || nextElementDepthFirst.tabIndex < 0 || nextElementDepthFirst.excludeFromFocusRing)
                {
                    nextElementDepthFirst = nextElementDepthFirst.GetNextElementDepthFirst();
                    bool flag2 = nextElementDepthFirst == null;
                    if (flag2)
                    {
                        nextElementDepthFirst = currentFocusable.GetRoot();
                    }
                    bool flag3 = nextElementDepthFirst == currentFocusable;
                    if (flag3)
                    {
                        result = currentFocusable;
                        return(result);
                    }
                }
                result = nextElementDepthFirst;
            }
            return(result);
        }