<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_last_node_for_prfx(self, node, key_prfx, seen_prfx):
 """ get last node for the given prefix, also update `seen_prfx` to track the path already traversed :param node: node in form of list, or BLANK_NODE :param key_prfx: prefix to look for :param seen_prfx: prefix already seen, updates with each call :return: BLANK_NODE if does not exist, otherwise value or hash """

        node_type = self._get_node_type(node)

        if node_type == NODE_TYPE_BLANK:
            return BLANK_NODE

        if node_type == NODE_TYPE_BRANCH:
            # already reach the expected node
            if not key_prfx:
                return node
            sub_node = self._decode_to_node(node[key_prfx[0]])
            seen_prfx.append(key_prfx[0])
            return self._get_last_node_for_prfx(sub_node, key_prfx[1:], seen_prfx)

        # key value node
        curr_key = key_nibbles_from_key_value_node(node)

        if node_type == NODE_TYPE_LEAF:
            # Return this node only if the complete prefix is part of the current key
            if starts_with(curr_key, key_prfx):
                # Do not update `seen_prefix` as node has the prefix
                return node
            else:
                return BLANK_NODE

        if node_type == NODE_TYPE_EXTENSION:
            # traverse child nodes
            if len(key_prfx) > len(curr_key):
                if starts_with(key_prfx, curr_key):
                    sub_node = self._get_inner_node_from_extension(node)
                    seen_prfx.extend(curr_key)
                    return self._get_last_node_for_prfx(sub_node,
                                                        key_prfx[len(curr_key):],
                                                        seen_prfx)
                else:
                    return BLANK_NODE
            else:
                if starts_with(curr_key, key_prfx):
                    # Do not update `seen_prefix` as node has the prefix
                    return node
                else:
                    return BLANK_NODE