python function returns more dicts
<p>Why is this recursive function returning more than 1 dictionary aka printing them each time it cycles why isn't it adding new findings to the existing dictionary.</p>

<p>And no i dont want to use os.walk and yes i am aware theres no return</p>

<pre><code>def retFiles(dir):
    data = {}
    root = set()
    os.chdir(dir)
    cwd = os.getcwd()
    for i in os.listdir(cwd):
        if os.path.isfile(i):
            data.setdefault(i, set())
            root.add(os.path.relpath(dir).replace("\\", "/"))
            data[i] = root
        else:
            retFiles(i)
    print(data)
</code></pre>
