code: def _find_longest_prefix_match(
      tree, bin_X, hash_size, left_masks, right_masks
  ):
      """Find the longest prefix match in tree for each query in bin_X
  
      Most significant bits are considered as the prefix.
      """
      hi = np.empty_like(bin_X, dtype=np.intp)
      hi.fill(hash_size)
      lo = np.zeros_like(bin_X, dtype=np.intp)
      res = np.empty_like(bin_X, dtype=np.intp)
  
      left_idx, right_idx = _find_matching_indices(
          tree, bin_X, left_masks[hi], right_masks[hi]
      )
      found = right_idx > left_idx
      res[found] = lo[found] = hash_size
  
      r = np.arange(bin_X.shape[0])
      kept = r[lo < hi]  # indices remaining in bin_X mask
      while kept.shape[0]:
          mid = (lo.take(kept) + hi.take(kept)) // 2
  
          left_idx, right_idx = _find_matching_indices(
              tree, bin_X.take(kept), left_masks[mid], right_masks[mid]
          )
          found = right_idx > left_idx
          mid_found = mid[found]
          lo[kept[found]] = mid_found + 1
          res[kept[found]] = mid_found
          hi[kept[~found]] = mid[~found]
  
          kept = r[lo < hi]
  
      return res
  
imports: import numpy
  import warnings
  from scipy import sparse
  from .base import KNeighborsMixin, RadiusNeighborsMixin
  from ..base import BaseEstimator
  from ..utils.validation import check_array
  from ..utils import check_random_state
  from ..metrics.pairwise import pairwise_distances
  from ..random_projection import GaussianRandomProjection
label_desc: Use image node_id 2 for calling a global function with example usage: _find_longest_prefix_match(tree, bin_X, hash_size, left_masks, right_masks) and returns: res