<p>Given the <code>root</code> of a binary tree and an integer <code>targetSum</code>, return <em>all <strong>root-to-leaf</strong> paths where the sum of the node values in the path equals </em><code>targetSum</code><em>. Each path should be returned as a list of the node <strong>values</strong>, not node references</em>.</p>

<p>A <strong>root-to-leaf</strong> path is a path starting from the root and ending at any leaf node. A <strong>leaf</strong> is a node with no children.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/01/18/pathsumii1.jpg" style="width: 500px; height: 356px;" />
<pre>
<strong>Input:</strong> root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22
<strong>Output:</strong> [[5,4,11,2],[5,8,4,5]]
<strong>Explanation:</strong> There are two paths whose sum equals targetSum:
5 + 4 + 11 + 2 = 22
5 + 8 + 4 + 5 = 22
</pre>

<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/01/18/pathsum2.jpg" style="width: 212px; height: 181px;" />
<pre>
<strong>Input:</strong> root = [1,2,3], targetSum = 5
<strong>Output:</strong> []
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> root = [1,2], targetSum = 0
<strong>Output:</strong> []
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li>The number of nodes in the tree is in the range <code>[0, 5000]</code>.</li>
	<li><code>-1000 &lt;= Node.val &lt;= 1000</code></li>
	<li><code>-1000 &lt;= targetSum &lt;= 1000</code></li>
</ul>

# Definition for a binary tree node.
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
class Solution:
    def pathSum(self, root, target_sum):
        memo_parent = {}
        memo_parent[root] = None

        inorder_nodes = []
        memo_paths = {}
        self.inorder_traversal(root, inorder_nodes, memo_parent, memo_paths)

        ret_val = []
        for node in memo_paths.keys():
            node_path = memo_paths[node]
            path_sum = sum([n.val for n in node_path])
            
            if (path_sum == target_sum):
                ret_val.append([n.val for n in node_path])
            
        return ret_val

    def inorder_traversal(self, node, inorder_nodes, memo_parent, memo_paths):
        if (node is None):
            return
        else:
            if (node.left is not None):
                memo_parent[node.left] = node
                self.inorder_traversal(node.left, inorder_nodes, memo_parent, memo_paths)
            
            if (node.right is not None):
                memo_parent[node.right] = node
                self.inorder_traversal(node.right, inorder_nodes, memo_parent, memo_paths)

            if (node.left is None
                and node.right is None):
                node_path = deque()
                curr_node = node
                while (curr_node is not None):
                    node_path.appendleft(curr_node)
                    curr_node = memo_parent[curr_node]
                
                memo_paths[node] = node_path
18600