def METHOD_NAME(node: Any) -> None:
    "Process node recursively."
    for child in node.childNodes:
        if child.nodeType == child.TEXT_NODE:
            result.append((get_current_style(), child.data))
        else:
            add_to_name_stack = child.nodeName not in (
                "#document",
                "html-root",
                "style",
            )
            fg = bg = ""
            for k, v in child.attributes.items():
                if k == "fg":
                    fg = v
                if k == "bg":
                    bg = v
                if k == "color":
                    fg = v  # Alias for 'fg'.
            # Check for spaces in attributes. This would result in
            # invalid style strings otherwise.
            if " " in fg:
                raise ValueError('"fg" attribute contains a space.')
            if " " in bg:
                raise ValueError('"bg" attribute contains a space.')
            if add_to_name_stack:
                name_stack.append(child.nodeName)
            if fg:
                fg_stack.append(fg)
            if bg:
                bg_stack.append(bg)
            METHOD_NAME(child)
            if add_to_name_stack:
                name_stack.pop()
            if fg:
                fg_stack.pop()
            if bg:
                bg_stack.pop()