def get_common_ancestor(name1, name2):
    common_parts = []
    for part1, part2 in zip(name1.split('.'), name2.split('.')):
        if part1 == part2:
            common_parts.append(part1)
        else:
            break

    if common_parts:
        return '.'.join(common_parts)
    else:
        return ''
Args
dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/util/string_util.py/get_common_ancestor