Nested subspace learning with flags