You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cross_project_reference.rb
    path of file: ./repos/gitlabhq/lib/banzai
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Banzai
  # Common methods for ReferenceFilters that support an optional cross-project
  # reference.
  module CrossProjectR
    
    def parent_from_ref(ref)
      return context[:project] || context[:group] unless ref
      return context[:project] if context[:project]&.full_path == ref

      if reference_cache.cache_loaded?
        # optimization to reuse the parent_per_reference query information
        reference_cache.parent_per_reference[ref || reference_cache.current_parent_path]
      else
        Project.find_by_full_path(ref)
      end