from typing import Union


def find_error_character(chunk: str) -> Union[str, None]:
    """Find the first illegal character for a given chunk."""

    stack = []

    bracket_mapping = {")": "(", "]": "[", "}": "{", ">": "<"}

    open_brackets = ["(", "[", "{", "<"]

    for char in chunk:

        if char in open_brackets:

            stack.append(char)

        else:

            top_char = stack.pop()

            if top_char != bracket_mapping[char]:

                return char

    return None