code: private void checkNotAncestor(File source, Directory destParent, FileSystemView destView)
        throws IOException {
      // if dest is not in the same file system, it couldn't be in source's subdirectories
      if (!isSameFileSystem(destView)) {
        return;
      }
  
      Directory current = destParent;
      while (true) {
        if (current.equals(source)) {
          throw new IOException(
              "invalid argument: can't move directory into a subdirectory of itself");
        }
  
        if (current.isRootDirectory()) {
          return;
        } else {
          current = current.parent();
        }
      }
    }
docs: Checks that source is not an ancestor of dest, throwing an exception if it is.