(parent, collect=set())
return collect
Recursively walk down a thread of posts starting from target
Recursively walk down a thread of posts starting from target
Recursively walk down a thread of posts starting from target
def walk_down_thread(parent, collect=set()):
    """
    Recursively walk down a thread of posts starting from target
    """

    # Stop condition: post does not have a root or parent.
    if (parent is None) or (parent.parent is None) or (parent.root is None):
        return collect

    # Get all children for this post, excluding itself.
    children = Post.objects.filter(parent=parent).exclude(uid=parent.uid)

    for child in children:
        # Add child to list
        collect.add(child)
        # Get all children belonging to the current child.
        walk_down_thread(parent=child, collect=collect)

    return collect
def walk_down_thread ( parent , collect = set ( ) ) : # Stop condition: post does not have a root or parent. if ( parent is None ) or ( parent . parent is None ) or ( parent . root is None ) : return collect # Get all children for this post, excluding itself. children = Post . objects . filter ( parent = parent ) . exclude ( uid = parent . uid ) for child in children : # Add child to list collect . add ( child ) # Get all children belonging to the current child. walk_down_thread ( parent = child , collect = collect ) return collect