code: public static List<OwnerAndPermission> resolveReplicatedOwnerAndPermissionsRecursively(FileSystem sourceFs, Path fromPath,
        Path toPath, CopyConfiguration copyConfiguration) throws IOException {
  
      if (!PathUtils.isAncestor(toPath, fromPath)) {
        throw new IOException(String.format("toPath %s must be an ancestor of fromPath %s.", toPath, fromPath));
      }
  
      List<OwnerAndPermission> ownerAndPermissions = Lists.newArrayList();
      Path currentPath = fromPath;
  
      while (PathUtils.isAncestor(toPath, currentPath.getParent())) {
        ownerAndPermissions.add(resolveReplicatedOwnerAndPermission(sourceFs, currentPath, copyConfiguration));
        currentPath = currentPath.getParent();
      }
  
      return ownerAndPermissions;
    }
docs: Compute the correct {@link OwnerAndPermission} obtained from replicating source owner and permissions and applying
  the {@link PreserveAttributes} rules for fromPath and every ancestor up to but excluding toPath.
  
  @return A list of the computed {@link OwnerAndPermission}s starting from fromPath, up to but excluding toPath.
  @throws IOException if toPath is not an ancestor of fromPath.