def eval_complex_cor_pattern(self, pattern, hosts, services,
                                 hostgroups, servicegroups, running=False):
        node = DependencyNode()
        pattern = self.eval_xof_pattern(node, pattern)
        in_par = False
        tmp = ''
        son_is_not = False
        stacked_parenthesis = 0
        for char in pattern:
            if char == '(':
                stacked_parenthesis += 1
                in_par = True
                tmp = tmp.strip()
                if stacked_parenthesis == 1 and tmp != '':
                    print("ERROR : bad expression near", tmp)
                    continue
                if stacked_parenthesis > 1:
                    tmp += char
            elif char == ')':
                stacked_parenthesis -= 1
                if stacked_parenthesis < 0:
                    print("Error : bad expression near", tmp, "too much ')'")
                    continue
                if stacked_parenthesis == 0:
                    tmp = tmp.strip()
                    son = self.eval_cor_pattern(tmp, hosts, services,
                                                hostgroups, servicegroups, running)
                    if son_is_not:
                        son.not_value = True
                        son_is_not = False
                    node.sons.append(son)
                    in_par = False
                    tmp = ''
                    continue
                tmp += char
            elif in_par:
                tmp += char
            elif char == '!':
                tmp = tmp.strip()
                if tmp and tmp[0] != '!':
                    print("Error : bad expression near", tmp, "wrong position for '!'")
                    continue
                son_is_not = True
            elif char in ['&', '|']:
                tmp = tmp.strip()
                if node.operand is not None and node.operand != 'of:' and char != node.operand:
                    return None
                if node.operand != 'of:':
                    node.operand = char
                if tmp != '':
                    son = self.eval_cor_pattern(tmp, hosts, services,
                                                hostgroups, servicegroups, running)
                    if son_is_not:
                        son.not_value = True
                        son_is_not = False
                    node.sons.append(son)
                tmp = ''
            else:
                tmp += char
        tmp = tmp.strip()
        if tmp != '':
            son = self.eval_cor_pattern(tmp, hosts, services,
                                        hostgroups, servicegroups, running)
            if son_is_not:
                son.not_value = True
                son_is_not = False
            node.sons.append(son)
        node.switch_zeros_of_values()
        return node