Nothing fancy, but I know many new programmers are often confused about recursion. Recursion simply is when a method calls itself.
What MyTree does is it adds nodes to the root node, then that root node can be used to create a JTree.
The populate() method reads in a list of Files into an array. If the file is a folder(directory), then populate() is called again. Only this time, the root node is a sub-folder of the root node that was originally passed in at the MyTree object's creation. Now why do we that? If the file in the File array is a folder, it may have sub folders. Instead of adding all those sub folders to the root node of the tree, they're added to its parent folder.
For example, lets say the initial root node represents "My Computer" on your computer. The path for the new File is "c:/". "C:/" becomes the root for any of the sub folders it contains. And the root for "c:/" is "My Computer". Let's assume you only have 2 folders visible directly under C:/, "Program Files" and "Windows". During the first pass through the populate method, "c:" is added to "My Computer", and then the rootAdded flag is set to true. "C:" is now the root from this point on. The first folder that is seen is "Program Files". That is now added to "C:", and populate() is called again to check for sub-folders. This time when it is called, "program files" becomes the root. So any folders added at that point will be seen under the "program files" node, or folder. This process continues until no more sub folders are found. The method then begins to end at each level that it was called. Eventually, the method ends until its back at the first time it was called. "C:" becomes the root again, and searches for more folders. It see "Windows" and adds it to "C:", and starts the whole procedure over again. This may sound confusing, but if you open up Windows File Explorer and follow along with a visual reference, it should make more sense. Hope this helps somebody.