If the leaf node is encountered , then the path is printed if the size of the path vector is greater than 0
if root . left is None and root . right is None : NEW_LINE INDENT if flag : NEW_LINE INDENT ans = 1 NEW_LINE print ( " ( " , end = " " ) NEW_LINE for i in range ( len ( path ) ) : NEW_LINE INDENT print ( path [ i ] , end = " , ▁ " ) NEW_LINE DEDENT print ( root . data , end = " ) , ▁ " ) NEW_LINE DEDENT return NEW_LINE DEDENT