def unmangle(name):
    """
    Attempts to unmangle a private mangled name.

    If the parent name contains underscores, it may not be recovered correctly:
    - Leading underscores are omitted.
    - If the name contains a double underscore, only the preceding part is
      recovered as the class name; the rest is part of the unmangeld name.

    :return:
      A guess at the parent name and the unmangled name.  If `name` is not
      mangled, returns `None, name`.
    """
    if not name.startswith('_') or name.startswith('__'):
        return None, name
    try:
        parent, unmangled = name[1:].split('__', 1)
    except ValueError:
        return None, name
    else:
        return parent, '__' + unmangled
