def remove_empty_leading_trailing(lines):
    """
    Removes leading and trailing empty lines.

    A list of strings is passed as argument, some of which may be empty.
    This function removes from the start and end of the list a contiguous
    sequence of empty lines and returns the result.  Embedded sequences of
    empty lines are not touched.

    Parameters:
    lines List of strings to be modified.

    Return:
    Input list of strings with leading/trailing blank line sequences
    removed.
    """

    retlines = []

    # Dispose of degenerate case of empty array
    if len(lines) == 0:
        return retlines

    # Search for first non-blank line
    start = 0
    while start < len(lines):
        if len(lines[start]) > 0:
            break
        start = start + 1

    # Handle case when entire list is empty
    if start >= len(lines):
        return retlines

    # Search for last non-blank line
    finish = len(lines) - 1
    while finish >= 0:
        if len(lines[finish]) > 0:
            break
        finish = finish - 1

    retlines = lines[start:finish + 1]
    return retlines