def _get_dependencies_recursively(
    initial_file_descriptors
):
  """Gets all dependencies of file_descriptors as a set (including itself)."""
  file_descriptor_set = set(initial_file_descriptors)
  boundary = list(initial_file_descriptors)
  while boundary:
    current = boundary.pop()
    for dependency in current.dependencies:
      if dependency not in file_descriptor_set:
        file_descriptor_set.add(dependency)
        boundary.append(dependency)
  return file_descriptor_set