import re


def address_group(address, group_name=None):
    """
    Return part of address upto group_name
    :param address: str hdf address
    :param group_name: str name of group
    :return: reduced str
    """
    if group_name is None:
        names = address.replace('\\', '/').split('/')
        return '/'.join(names[:-1])
    return re.findall(r'(.+?%s.*?)(?:\/|$)' % group_name, address, re.IGNORECASE)[0]