Implement a standard binary search to find the first or last occurrence of a target element in a sorted array with duplicates.
Write find_occurrence(nums, target, find_first), where find_first determines whether to return the first or last matching index. Return -1 if the target does not occur; the input array may be empty.
def find_occurrence(nums, target, find_first):