Flatten:
PROC [cellType: Core.CellType, expand: ExpandProc]
RETURNS [flat: Core.CellType, isRecordCell:
BOOL ←
TRUE];
Each descendent is expanded or not, depending on what expand says. The flat cellType returned is either a recordCell (isRecordCell=TRUE) made of atomic objects, or an atomic object (with respect to expand). Expand might be arbitrarily complex, for example, expand can look at some properties and act depending on them. The decision of whether to expand or stop is made at each node in the hierarchy.
Some strange copying (including some geometrical transformations) is done on some properties.
NonTransistorsExpand: ExpandProc
expands instances whose class is not CoreTransistor.transistorCellClass