def _internal_check_encoded_path_is_dir( path ):
    """
        Need this complex structure to support UTF-8 file names in Python 2.7
    """

    import os
    import sys

    try:
        if os.path.isdir( path ):
            return path
    except Exception as e:

        try:
            path = path.encode('utf-8')
            if os.path.isdir( path ):
                return path
        except Exception as e:

            try:
                path = path.encode(sys.stdin.encoding)
                if os.path.isdir(p):
                    return path
            except Exception as e:
                pass

    return None