def get_cfg_path(cfg, entry=None, sep="."):
    """Get a string representing the path of a ConfigObj through sections

    Parameters
    ----------
    cfg: configobj.ConfigObj
    entry: str, None
    sep: str

    Example
    -------
    >>> c=configobj.ConfigObj({'a':{'b':{'c':'d'}}})
    >>> get_cfg_path(c['a']['b'])
    'a.b'
    >>> get_cfg_path(c['a'], 'b')
    'a.b'
    >>> get_cfg_path(c['a']['b'], 'c', '::')
    'a::b::c'

    """
    ancestors = []
    if entry is not None:
        ancestors.append(entry)
    curcfg = cfg
    while curcfg.depth > 0 and curcfg.parent is not curcfg:
        ancestors.append(curcfg.name)
        curcfg = curcfg.parent
    return sep.join(reversed(ancestors))