<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_option(self, block, name):
 """ Removes first matching option that exists from the AST. `block` Block name. Set to ``None`` for non-block option. `name` Option name to remove. * Raises a ``ValueError`` exception if `name` and/or `block` haven't been added. """


        if block:
            # block doesn't exist
            if not self._ast or not block in self._block_map:
                raise ValueError(u"Block '{0}' does not exist"
                                 .format(common.from_utf8(block)))

            # lookup block index and remove
            block_idx = self._block_map[block]

            for i, opt in enumerate(self._ast[2][block_idx][1]):
                if opt[0] == name:
                    item_idx = i
                    break
            else:
                raise ValueError(u"Option '{0}' does not exist"
                                 .format(common.from_utf8(name)))

            # pop off the block option
            options = self._ast[2][block_idx][1]
            options.pop(item_idx)

        else:
            if not self._ast:
                raise ValueError(u"Option '{0}' does not exist"
                                 .format(common.from_utf8(name)))

            # non-block option
            for i, opt in enumerate(self._ast[1]):
                if opt[0] == name:
                    item_idx = i
                    break
            else:
                raise ValueError(u"Option '{0}' does not exist"
                                 .format(common.from_utf8(name)))

            # pop off non-block option
            self._ast[1].pop(item_idx)