<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_empty_dir(path):
 """ Function to remove empty folders """

    try:
        if not os.path.isdir(path):
            return

        files = os.listdir(path)

        # if folder empty, delete it
        if len(files) == 0:
            os.rmdir(path)

        # remove empty subdirectory
        elif len(files) > 0:
            for f in files:
                abspath = os.path.join(path, f)
                if os.path.isdir(abspath):
                    remove_empty_dir(abspath)
    except OSError as e:
        if e.errno == errno.ENOTEMPTY:
            pass