def get_group(parser, group_name, env_var_prefix=None):
    """
    Return an argument group based on the group name.

    This will return an existing group if it exists, or create a new one.

    :argument parser: :py:class:`python3:argparse.ArgumentParser` to
                      add/retrieve the group to/from.
    :argument group_name: Name of the argument group to be created/returned.
    :argument env_var_prefix: Prefix to use for the environment variables support of this group. If set to None,
                              uses the title of the _ArgumentGroup that this is wrapping. If not set or set to False,
                              does not add any prefix. This argument MUST be a keyword argument.
    """

    # We don't want to add an additional group if there's already a 'logging'
    # group. Sadly, ArgumentParser doesn't provide an API for this, so we have
    # to be naughty and access a private variable.
    groups = [g.title for g in parser._action_groups]  # pylint: disable=protected-access

    if group_name in groups:
        group = parser._action_groups[groups.index(group_name)]  # pylint: disable=protected-access
    else:
        group = parser.add_argument_group(title=group_name, env_var_prefix=env_var_prefix)

    return group