<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def GetArtifactsDependenciesClosure(name_list, os_name=None):
 """For all the artifacts in the list returns them and their dependencies."""


  artifacts = set(REGISTRY.GetArtifacts(os_name=os_name, name_list=name_list))

  dependencies = set()
  for art in artifacts:
    dependencies.update(GetArtifactDependencies(art, recursive=True))
  if dependencies:
    artifacts.update(
        set(
            REGISTRY.GetArtifacts(
                os_name=os_name, name_list=list(dependencies))))

  return artifacts