<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def eval_cor_pattern(self, pattern, hosts, services, hostgroups, servicegroups, running=False):
 """Parse and build recursively a tree of DependencyNode from pattern :param pattern: pattern to parse :type pattern: str :param hosts: hosts list, used to find a specific host :type hosts: alignak.objects.host.Host :param services: services list, used to find a specific service :type services: alignak.objects.service.Service :param running: rules are evaluated at run time and parsing. True means runtime :type running: bool :return: root node of parsed tree :rtype: alignak.dependencynode.DependencyNode """

        pattern = pattern.strip()
        complex_node = False

        # Look if it's a complex pattern (with rule) or
        # if it's a leaf of it, like a host/service
        for char in '()&|':
            if char in pattern:
                complex_node = True

        # If it's a simple node, evaluate it directly
        if complex_node is False:
            return self.eval_simple_cor_pattern(pattern, hosts, services,
                                                hostgroups, servicegroups, running)
        return self.eval_complex_cor_pattern(pattern, hosts, services,
                                             hostgroups, servicegroups, running)