TikZ allows you to reference nodes outside the current picture. This feature is enabled using the remember picture option.
remember picture
Subscribe to the TikZ examples RSS feed