def _yield_children(rec):
    '''
    An internal function to gather and yield all of the children of a Directory
    Record.
    Parameters:
     rec - The Directory Record to get all of the children from (must be a
           directory)
    Yields:
     Children of this Directory Record.
    Returns:
     Nothing.
    '''
    if not rec.is_dir():
        raise pycdlibexception.PyCdlibInvalidInput('Record is not a directory!')
    last = b''
    for child in rec.children:
        fi = child.file_identifier()
        if fi == last:
            continue
        last = fi
        if child.rock_ridge is not None and child.rock_ridge.child_link_record_exists() and child.rock_ridge.cl_to_moved_dr is not None and child.rock_ridge.cl_to_moved_dr.parent is not None:
            cl_parent = child.rock_ridge.cl_to_moved_dr.parent
            for cl_child in cl_parent.children:
                if cl_child.rock_ridge is not None and cl_child.rock_ridge.name() == child.rock_ridge.name():
                    child = cl_child
                    break
        yield child