Index: src/hg/hgTables/schema.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTables/schema.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -b -B -U 4 -r1.60 -r1.61
--- src/hg/hgTables/schema.c	20 May 2009 20:59:56 -0000	1.60
+++ src/hg/hgTables/schema.c	4 Jan 2010 19:12:23 -0000	1.61
@@ -581,11 +581,13 @@
             return TRUE;
     }
 else if (curTrack->subtracks != NULL)
     {
-    struct trackDb *sTdb = NULL;
-    for (sTdb = curTrack->subtracks;  sTdb != NULL;  sTdb = sTdb->next)
+    struct slRef *tdbRefList = trackDbListGetRefsToDescendantLeaves(curTrack->subtracks);
+    struct slRef *tdbRef;
+    for (tdbRef = tdbRefList; tdbRef != NULL; tdbRef = tdbRef->next)
         {
+	struct trackDb *sTdb = tdbRef->val;
         if (sameString(sTdb->tableName, curTable))
             return TRUE;
         }
     }

