             i = i - 1
         }
         desc += " \(node.name)\n"
-        for child in node.children {
+        
+        guard node.isDirectory else {
+            return desc
+        }
+        
+        for child in node.children! {
             desc += traverseNode(level+1, node: child)
         }
         return desc


class PathNode: NSObject {
    var name : String!
    private var children : [PathNode]!
    var parent : PathNode?
    
    override init() {
        super.init()
        children = [PathNode]()
    }
    
    func addChild(child : PathNode) -> Bool {
        children.append(child)
        child.parent = self
        return true
    }
    
    func treepath() -> String! {

    func loadChildren() {
        let syspath = self.syspath()
        let fileManager = NSFileManager.defaultManager()
        let components = try? fileManager.contentsOfDirectoryAtPath(syspath)
        
        guard let _ = components else {
            return
        }
        
        guard components!.count != 0 else {
            return
        }
        
        for element in components! {
            let path = self.syspath() + "/\(element)"
            var isDir = ObjCBool(false)
            fileManager.fileExistsAtPath(path, isDirectory: &isDir)
            
            let node = PathNode(isDirectory: isDir.boolValue, name: element)
            self.addChild(node)
            node.loadChildren()
        }
