def _find_in_sequence(indices, sequence):
    """Helper function for ncon.

    check if the supplied indices appear at the beginning of sequence

    Parameters
    ----------
    indices : list of int
    sequence : list of int

    Returns
    -------
    idcs : list of int
        All the given indices that appear consecutively at the front of sequence
    """
    ptr = 0
    while ptr < len(sequence) and sequence[ptr] in indices:
        ptr = ptr + 1
    rtn_indices = sequence[:ptr]
    sequence = sequence[ptr:]
    return rtn_indices, sequence
