     var stack = [self.root]
 
     while let item = stack.popLast() {
-      if item.isChildrenScanned == false {
-        item.children = FileUtils.directDescendants(of: item.url).map(FileBrowserItem.init)
-        item.isChildrenScanned = true
-      }
-
+      self.scanChildrenIfNecessary(item)
       itemsToExpand.append(item)
 
       if item.url.isDirectParent(of: url) {

    }

    if fileBrowserItem.url.isDir {
      if fileBrowserItem.isChildrenScanned == false {
        fileBrowserItem.children = self.sortedChildren(of: fileBrowserItem.url)
        fileBrowserItem.isChildrenScanned = true
      }

      return self.prepare(fileBrowserItem.children).count
    }


// MARK: - NSOutlineViewDataSource
extension FileOutlineView {

  fileprivate func scanChildrenIfNecessary(_ fileBrowserItem: FileBroswerItem) {
    guard fileBrowserItem.isChildrenScanned == false else {
      return
    }

    fileBrowserItem.children = self.sortedChildren(of: fileBrowserItem.url)
    fileBrowserItem.isChildrenScanned = true
  }

  fileprivate func prepare(_ children: [FileBrowserItem]) -> [FileBrowserItem] {
    return self.isShowHidden ? children : children.filter { !$0.url.isHidden }
  }

  func outlineView(_: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
    if item == nil {
      self.scanChildrenIfNecessary(self.root)

      return self.prepare(self.root.children).count
    }
