<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def distribution_from_path(cls, path, name=None):
 """Return a distribution from a path. If name is provided, find the distribution. If none is found matching the name, return None. If name is not provided and there is unambiguously a single distribution, return that distribution otherwise None. """

    # Monkeypatch pkg_resources finders should it not already be so.
    register_finders()
    if name is None:
      distributions = set(find_distributions(path))
      if len(distributions) == 1:
        return distributions.pop()
    else:
      for dist in find_distributions(path):
        if dist.project_name == name:
          return dist