I don't think there is a tool in blender which allows you to do it automatically (you may try to ask another question how to do it by scripting though). Here's my method which uses a pinning option. Place two UV islands close to each other. Enable the snapping tool (vertex) and snap all the external vertices of one island to the vertices of the other to match islands' shapes.
Now select the rim of the first island (Alt+RMB) and press P to pin it. Press L to select the whole island and hide it (H). Repeat the pinning process for the second island. Next unhide the first one with Alt+H, select both (A) and unwrap again. Finally unpin everything with Alt+P.