Ensure that the directory tree traversal stops after the first match