Updated analyze module to handle more complicated relations without recursive iterations over relations