The WebDriver API does not support getting the current frame/iframe. The JS API does, however, this information can not be used to switch to the frame. Secondly, it is not possible to switch back to the previous iframe without switching to the default content firstly and then traversing to the previous iframe.

IMHO the functionality can be implemented in a way that there will be built a tree structure with the switched iframes, stored in some static context. *However*, as I mentioned it will have to switch back to the default frame firstly, and traverse that tree from there. And in result it would work as it works now.