Discovering Hidden Variables: A Structure-Based Approach