NameError: name '*' is not defined : <p>Why this line <code>add(root, sum, 0)</code> gets <code>NameError: name 'add' is not defined</code> error?</p>

<pre><code>class Solution:
    def rob(root: TreeNode) -&gt; int:
        sum = [0, 0]
        add(root, sum, 0)
        if sum[0] &lt; sum[1]:
            return sum[1]
        else:
            return sum[0]

    def add(node: TreeNode, sum: List[int], index: int):
        if not node:
            return
        sum[index] += node.val
        index += 1
        if index &gt;= len(sum):
            index = 0;
        add(node.left, sum, index)
        add(node.right, sum, index)
</code></pre>
