Index: /branches/eam_branch_20080706/psModules/src/camera/pmHDUUtils.c
===================================================================
--- /branches/eam_branch_20080706/psModules/src/camera/pmHDUUtils.c	(revision 18430)
+++ /branches/eam_branch_20080706/psModules/src/camera/pmHDUUtils.c	(revision 18431)
@@ -9,4 +9,25 @@
 #include "pmFPA.h"
 #include "pmHDUUtils.h"
+
+pmHDU *pmHDUGetFirst (const pmFPA *fpa) {
+
+  // XXX we probably should have an indicator in pmFPA about the depths.
+
+  if (!fpa) return NULL;
+  if (fpa->hdu) return fpa->hdu;
+
+  for (int i = 0; i < fpa->chips->n; i++) {
+    pmChip *chip = fpa->chips[i];
+    if (!chip) continue;
+    if (chip->hdu) return chip->hdu;
+    if (!chip->cells) continue;
+    for (int j = 0; j < chip->cells->n; j++) {
+      pmCell *cell = chip->cells[j];
+      if (!cell) continue;
+      if (cell->hdu) return cell->hdu;
+    }
+  }
+  return NULL;
+}
 
 pmHDU *pmHDUFromFPA(const pmFPA *fpa)
Index: /branches/eam_branch_20080706/psModules/src/camera/pmHDUUtils.h
===================================================================
--- /branches/eam_branch_20080706/psModules/src/camera/pmHDUUtils.h	(revision 18430)
+++ /branches/eam_branch_20080706/psModules/src/camera/pmHDUUtils.h	(revision 18431)
@@ -4,6 +4,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-03-30 21:12:56 $
+ * @version $Revision: 1.9.46.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-07-07 04:23:26 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -14,4 +14,7 @@
 /// @addtogroup Camera Camera Layout
 /// @{
+
+/// Get the first HDU encountered in the hierarchy
+pmHDU *pmHDUGetFirst (const pmFPA *fpa);
 
 /// Get the lowest HDU in the hierarchy
