def branches(self):
        """ Returns a :class:`QuerySet` of all branch nodes (nodes with at least
            one child).

            :return: A :class:`QuerySet` of all leaf nodes (nodes with at least
                one child).
        """
        # We need to read the _cte_node_children attribute, so ensure it exists.
        self._ensure_parameters()
        return self.filter(
            **{"%s__id__in" % self.model._cte_node_children: self.all()}
        ).distinct()