It sounds like you're cramming all of the relationship data into the one list. It's better DB practice - and will make the function work the way you want it to - if you normalize the data into separate lists. Take a look at the example in the docs using Region, State, etc.
M.
M.