private static Widget findChildByNameInAllGroups(final String name,
                                                     List<Widget> groups) {
        if (groups.isEmpty()) {
            return null;
        }

        ArrayList<Widget> groupChildren = new ArrayList<>();
        Widget result;
        for (Widget group : groups) {
            // Search the immediate children of 'groups' for a match, rathering
            // the children that are GroupWidgets themselves.
            result = findChildByNameInOneGroup(name, group, groupChildren);
            if (result != null) {
                return result;
            }
        }

        // No match; Search the children that are GroupWidgets.
        return findChildByNameInAllGroups(name, groupChildren);
    }
private static Widget findChildByNameInAllGroups ( final String name , List < Widget > groups ) { if ( groups . isEmpty ( ) ) { return null ; } ArrayList < Widget > groupChildren = new ArrayList < > ( ) ; Widget result ; for ( Widget group : groups ) { result = findChildByNameInOneGroup ( name , group , groupChildren ) ; if ( result != null ) { return result ; } } return findChildByNameInAllGroups ( name , groupChildren ) ; }
Performs a breadth-first search of the {@link GroupWidget GroupWidgets}
in {@code groups} for a {@link Widget} with the specified
{@link Widget#getName() name}.

@param name
The name of the {@code Widget} to find.
@param groups
The {@code GroupWidgets} to search.
@return The first {@code Widget} with the specified name or {@code null}
if no child of {@code groups} has that name.