def find_min_max(items, idx, heap_type):
    """
    Returns the index of the node with the max/min value between two children.
    """
    size = len(items) - 1
    left = 2 * idx
    right = 2 * idx + 1

    # if only one child it must be the left node
    if (right > size):
        return left

    # Check if the left node has the max/min value
    if (heap_type == 'max'):
        flag = items[left] > items[right]
    else:
        flag = items[left] < items[right]

    # Assign the index with the max/min
    ic = left if (flag) else right

    return ic