def get_reference_repository(self, reference: Optional[Path], repo: str) -> Optional[Path]:
if reference is not None:<EOL><INDENT>return reference.absolute()<EOL><DEDENT>repo_path = self.get_path_to_repo(repo)<EOL>if not repo_path.exists():<EOL><INDENT>return None<EOL><DEDENT>master = repo_path / "<STR_LIT>"<EOL>if master.exists() and master.is_dir():<EOL><INDENT>return master<EOL><DEDENT>for existing_branch in repo_path.iterdir():<EOL><INDENT>if not existing_branch.is_dir():<EOL><INDENT>continue<EOL><DEDENT>return existing_branch.resolve()<EOL><DEDENT>return None<EOL>
Returns a repository to use in clone command, if there is one to be referenced.
Either provided by the user of generated from already cloned branches (master is preferred).

:param reference: Path to a local repository provided by the user or None.
:param repo: Reference for which remote repository.