prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  get_last_root_page template tag not working
  ### Describe the Bug
  <!-- A clear and concise description of what the bug is. -->
  The `get_last_root_page` template tag is not working:
  https://github.com/Integreat/integreat-cms/blob/develop/src/cms/templatetags/page_filters.py#L10-L20
  
  This is because in the page QuerySet aggregation, the difference() function is used:
  https://github.com/Integreat/integreat-cms/blob/a285cb3c74b2a2c501147076338e2b2a70c89bd6/src/cms/models/regions/region.py#L177
  
  After difference(), it is not possible to use filter(), see https://docs.djangoproject.com/en/2.2/ref/models/querysets/#union
  
  This leads to the last drop-region in the page tree being incorrectly tied to the last page in the list, not necessarily the last root page.
  
  ### Steps to Reproduce
  
  1. Go to Page tree
  2. Drag & drop page to most bottom line
  
  ### Expected Behavior
  <!-- A clear and concise description of what you expected to happen. -->
  The page should be placed next to the last root page
  
  ### Actual Behavior
  <!-- A clear and concise description of what actually happened. -->
  The page is placed next to the last page in the list
  
  ### Additional Information
  <!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->
  
  
  
  </issue>
  <code>
  [start of src/cms/templatetags/page_filters.py]
  1 """
  2 This is a collection of tags and filters for :class:`~cms.models.pages.page.Page` objects.
  3 """
  4 from django import template
  5 
  6 register = template.Library()
  7 
  8 
  9 @register.simple_tag
  10 def get_last_root_page(pages):
  11     """
  12     This tag returns the last page on the root level.
  13 
  14     :param pages: The requested page tree
  15     :type pages: ~mptt.querysets.TreeQuerySet [ ~cms.models.pages.page.Page ]
  16 
  17     :return: The last root page of the given :class:`~django.db.models.query.QuerySet`
  18     :rtype: ~cms.models.pages.page.Page
  19     """
  20     return pages.filter(parent=None).last()
  21
  [end of src/cms/templatetags/page_filters.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/cms/templatetags/page_filters.py b/src/cms/templatetags/page_filters.py
  --- a/src/cms/templatetags/page_filters.py
  +++ b/src/cms/templatetags/page_filters.py
  @@ -12,9 +12,9 @@
       This tag returns the last page on the root level.
   
       :param pages: The requested page tree
  -    :type pages: ~mptt.querysets.TreeQuerySet [ ~cms.models.pages.page.Page ]
  +    :type pages: list [ ~cms.models.pages.page.Page ]
   
  -    :return: The last root page of the given :class:`~django.db.models.query.QuerySet`
  +    :return: The last root page of the given page list
       :rtype: ~cms.models.pages.page.Page
       """
  -    return pages.filter(parent=None).last()
  +    return list(filter(lambda p: not p.parent, pages))[-1]
  
verification_info: {"golden_diff": "diff --git a/src/cms/templatetags/page_filters.py b/src/cms/templatetags/page_filters.py\n--- a/src/cms/templatetags/page_filters.py\n+++ b/src/cms/templatetags/page_filters.py\n@@ -12,9 +12,9 @@\n     This tag returns the last page on the root level.\n \n     :param pages: The requested page tree\n-    :type pages: ~mptt.querysets.TreeQuerySet [ ~cms.models.pages.page.Page ]\n+    :type pages: list [ ~cms.models.pages.page.Page ]\n \n-    :return: The last root page of the given :class:`~django.db.models.query.QuerySet`\n+    :return: The last root page of the given page list\n     :rtype: ~cms.models.pages.page.Page\n     \"\"\"\n-    return pages.filter(parent=None).last()\n+    return list(filter(lambda p: not p.parent, pages))[-1]\n", "issue": "get_last_root_page template tag not working\n### Describe the Bug\r\n<!-- A clear and concise description of what the bug is. -->\r\nThe `get_last_root_page` template tag is not working:\r\nhttps://github.com/Integreat/integreat-cms/blob/develop/src/cms/templatetags/page_filters.py#L10-L20\r\n\r\nThis is because in the page QuerySet aggregation, the difference() function is used:\r\nhttps://github.com/Integreat/integreat-cms/blob/a285cb3c74b2a2c501147076338e2b2a70c89bd6/src/cms/models/regions/region.py#L177\r\n\r\nAfter difference(), it is not possible to use filter(), see https://docs.djangoproject.com/en/2.2/ref/models/querysets/#union\r\n\r\nThis leads to the last drop-region in the page tree being incorrectly tied to the last page in the list, not necessarily the last root page.\r\n\r\n### Steps to Reproduce\r\n\r\n1. Go to Page tree\r\n2. Drag & drop page to most bottom line\r\n\r\n### Expected Behavior\r\n<!-- A clear and concise description of what you expected to happen. -->\r\nThe page should be placed next to the last root page\r\n\r\n### Actual Behavior\r\n<!-- A clear and concise description of what actually happened. -->\r\nThe page is placed next to the last page in the list\r\n\r\n### Additional Information\r\n<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->\r\n\r\n\n", "before_files": [{"content": "\"\"\"\nThis is a collection of tags and filters for :class:`~cms.models.pages.page.Page` objects.\n\"\"\"\nfrom django import template\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef get_last_root_page(pages):\n    \"\"\"\n    This tag returns the last page on the root level.\n\n    :param pages: The requested page tree\n    :type pages: ~mptt.querysets.TreeQuerySet [ ~cms.models.pages.page.Page ]\n\n    :return: The last root page of the given :class:`~django.db.models.query.QuerySet`\n    :rtype: ~cms.models.pages.page.Page\n    \"\"\"\n    return pages.filter(parent=None).last()\n", "path": "src/cms/templatetags/page_filters.py"}]}