<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def do_expand_array(self, array_name, depth=0):
 """Do recurrent array expansion, returning a set of keywords. Exception is thrown when there are cyclical dependencies between arrays or if the ``@array`` name references an undefined array. :param str array_name: The name of the array to expand. :param int depth: The recursion depth counter. :return set: The final set of array entries. """

        if depth > self.master._depth:
            raise Exception("deep recursion detected")
        if not array_name in self.master._array:
            raise Exception("array '%s' not defined" % (array_name))
        ret = list(self.master._array[array_name])
        for array in self.master._array[array_name]:
            if array.startswith('@'):
                ret.remove(array)
                expanded = self.do_expand_array(array[1:], depth+1)
                ret.extend(expanded)

        return set(ret)