def get_stmt_node_at_position(self, pos):
        """
        Iteratively finds the first valid node inside the GUI display that is not None.
        Finds the node based on the postion given (usually related to the mouse location).
        The function can return any valid Cxxx class inside the angr decompiler.

        Algorithm: O(n)
        This algorithm will search the position map by alternating between extended it's left and right search
        until we either hit the EOL or newline on the left and right. We stop either side searching once we
        hit a newline or EOL as well. In addition, we keep a special case for when the cursor is off the screen
        to simply put it back on the screen.

        :param pos:
        :return:
        """

        if self._codegen is None or self._codegen.map_pos_to_addr is None:
            return None

        n = self._codegen.map_pos_to_addr.get_node(pos)

        # if we can't find a node at the current position, start the algorithm search
        # from the left and right iteratively.
        if n is None:
            # special case where cursor is off the screen, reposition to before the end
            length = len(self._codegen.text) - 4 if pos >= len(self._codegen.text) - 2 else pos - 1

            r = pos + 1
            inc_l = not self._pos_is_newline_or_oob(length)
            inc_r = not self._pos_is_newline_or_oob(r)

            # iterate until we hit start or end of document
            while inc_l or inc_r:
                # continue left search if we are still at a valid char
                if inc_l:
                    n = self._codegen.map_pos_to_addr.get_node(length)
                    if n is not None:
                        break
                    length -= 1
                    inc_l = not self._pos_is_newline_or_oob(length)

                # continue right search if we are still at a valid char
                if inc_r:
                    n = self._codegen.map_pos_to_addr.get_node(r)
                    if n is not None:
                        break
                    r += 1
                    inc_r = not self._pos_is_newline_or_oob(r)

        return n

        Iteratively finds the first valid node inside the GUI display that is not None.
        Finds the node based on the postion given (usually related to the mouse location).
        The function can return any valid Cxxx class inside the angr decompiler.

        Algorithm: O(n)
        This algorithm will search the position map by alternating between extended it's left and right search
        until we either hit the EOL or newline on the left and right. We stop either side searching once we
        hit a newline or EOL as well. In addition, we keep a special case for when the cursor is off the screen
        to simply put it back on the screen.

        :param pos:
        :return:
        
angrmanagement/ui/documents/qcodedocument.py