<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_path(self, path):
 """ Remove an object """

        curpath = os.path.abspath(os.curdir)
        if not os.path.exists(path):
            logger.warn("Attempted to remove a non-existent path %s" % path)
            return
        try:
            if os.path.islink(path):
                os.unlink(path)
            elif os.path.isdir(path):
                shutil.rmtree(path)
            else:
                os.unlink(path)

            # in the case we just deleted ourselves out of a valid directory,
            # we move to a valid directory.
            if curpath == path:
                os.chdir(tempfile.gettempdir())

        except OSError:
            logger.error("Unable to remove object at path %s" % path)
            raise DirectoryException("Unable to remove object at path %s" % path)