Efficient Relational Learning with Hidden Variable Detection