     }
 
     public func removeFileTree(_ path: AbsolutePath) throws {
-        // Ignore root and get the parent node's content if its a directory.
-        guard !path.isRoot,
-              let parent = try? getNode(path.parentDirectory),
-            case .directory(let contents) = parent.contents else {
-            return
-        }
-        // Set it to nil to release the contents.
-        contents.entries[path.basename] = nil
+        return lock.withLock {
+            // Ignore root and get the parent node's content if its a directory.
+            guard !path.isRoot,
+                  let parent = try? getNode(path.parentDirectory),
+                case .directory(let contents) = parent.contents else {
+                return
+            }
+            // Set it to nil to release the contents.
+            contents.entries[path.basename] = nil
+        }
     }
 
     public func chmod(_ mode: FileMode, path: AbsolutePath, options: Set<FileMode.Option>) throws {
         // FIXME: We don't have these semantics in InMemoryFileSystem.
     }
-
-    public func copy(from sourcePath: AbsolutePath, to destinationPath: AbsolutePath) throws {
+    
+    /// Private implementation of core copying function.
+    /// Not threadsafe.
+    private func _copy(from sourcePath: AbsolutePath, to destinationPath: AbsolutePath) throws {
         // Get the source node.
         guard let source = try getNode(sourcePath) else {
             throw FileSystemError.noEntry

            }
        }
    }
    private class DirectoryContents {
        var entries: [String: Node]


        }
    }

    /// The root node of the filesytem.
    private var root: Node
    
    /// Protects `root` and everything underneath it.
    /// FIXME: Using a single lock for this is a performance problem, but in
    /// reality, the only practical use for InMemoryFileSystem is for unit
    /// tests.
    private let lock = Lock()
    
    /// Exclusive file system lock vended to clients through `withLock()`.
    private let lockFilesLock = Lock()

    public init() {
