First, the free version and the Pro version work differently at the moment, so the method of doing this would be different.
In the pro version there is a function
acf_get_field_groups() that can be used to get a list of field groups.
In the free version there is a filter that can be used,
$field_groups = apply_filters('acf/get_field_groups', array());
You’ll need to look into the ACF code to get more details.
I usually do this on the ACF Pro hook “acf/include_fields” with a high priority so that all other fields groups are already included before I check to see what field groups already exist.
A word of caution. I have had this interfere with other plugins. I’ve had this happen recently with a site and all of the problems were with plugins created by https://yithemes.com/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!