if (potentialTarget instanceof CollapsableContent) {
if (potentialTarget != null && potentialTarget instanceof CollapsableContent) {
    private static CollapsableContent collapseAdjoiningIntervening(LayoutContext c, CachingContent parent, float parentWidth,                                                                   CollapsableContent target, List collapsed, int direction) {        CollapsableContent currentTarget = target;        while (true) {            c.pushStyle(currentTarget.getStyle());            try {                List adjoining = areMarginsAdjoining(c, currentTarget, parentWidth);                if (adjoining != null) {                    CollapsedMarginPair pair = collapseAdjoining(null, adjoining);                                        // bit of a hack, but it works                                        CollapsingMargin top = new CollapsingMargin();                    top.content = currentTarget;                    top.marginWidth = pair.getMaxNegative();                    collapsed.add(top);                    CollapsingMargin bottom = new CollapsingMargin();                    bottom.content = currentTarget;                    bottom.marginWidth = pair.getMaxPositive();                    collapsed.add(bottom);                    Object potentialTarget = null;                    if (direction == DIR_DOWN) {                        potentialTarget = parent.getNextInFlowSibling(c, currentTarget);                    } else if (direction == DIR_UP) {                        potentialTarget = parent.getPreviousInFlowSibling(c, currentTarget);                    } else {                        throw new IllegalArgumentException();                    }                    if (potentialTarget instanceof CollapsableContent) {                        currentTarget = (CollapsableContent) potentialTarget;                    } else {                        return null;                    }                } else {                    return currentTarget;                }            } finally {                c.popStyle();            }        }    }