code: def _pipdeptree(python_bin, package_name: str = None, warn: bool = False) -> typing.Optional[dict]:
      
      cmd = "{} -m pipdeptree --json".format(python_bin)
  
      _LOGGER.debug("Obtaining pip dependency tree using: %r", cmd)
      output = run_command(cmd, is_json=True).stdout
  
      if not package_name:
          return output
  
      for entry in output:
          # In some versions pipdeptree does not work with --packages flag, do the logic on out own.
          # TODO: we should probably do difference of reference this output and original environment
          if entry["package"]["key"].lower() == package_name.lower():
              return entry
  
      # The given package was not found.
      if warn:
          _LOGGER.warning("Package %r was not found in pipdeptree output %r", package_name, output)
      return None
docs: Get pip dependency tree by executing pipdeptree tool.