public static List<String> findSubGroupNames(final List<Token> tokens)
    {
        final ArrayList<String> groupNames = new ArrayList<>();
        int level = 0;

        for (final Token token : tokens)
        {
            if (token.signal() == Signal.BEGIN_GROUP)
            {
                if (level++ == 0)
                {
                    groupNames.add(token.name());
                }
            }

            if (token.signal() == Signal.END_GROUP)
            {
                level--;
            }
        }

        return groupNames;
    }
Find a list of subgroup names.

@param tokens to search.
@return list of names for the subgroups.
sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/GenerationUtil.java