Fixed api to handle nested foreign key searches