extract pattern from depdency relations sotred in mongo