Refactored nested_foreign_keys len() to count().