<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_pattern(self):
 """ It returns its url pattern """

        if self.is_root_node():
            return ""
        else:
            parent_pattern = self.parent.get_pattern()
            if parent_pattern != "":
                parent_pattern = u"{}".format(parent_pattern)
            if not self.page and not self.is_leaf_node():
                if self.hide_in_url:
                    return u'{0}'.format(parent_pattern)
                else:
                    return u'{0}{1}'.format(parent_pattern, self.name)
            else:
                if self.is_leaf_node() and self.page.regex and self.page.show_regex:
                    return u'{0}{1}/{2}'.format(parent_pattern, self.page.slug, self.page.regex)
                elif self.is_leaf_node() and (not self.page.regex or not self.page.show_regex):
                    return u'{0}{1}/'.format(parent_pattern, self.page.slug)
                elif not self.is_leaf_node() and self.page.regex and self.page.show_regex:
                    return u'{0}{1}/{2}/'.format(parent_pattern, self.page.slug, self.page.regex)
                else:
                    return u'{0}{1}/'.format(parent_pattern, self.page.slug)