def METHOD_NAME(layer, channel, real_mask=True):
    def _find_channel(layer, width, height, condition):
        depth, version = layer._psd.depth, layer._psd.version
        iterator = zip(layer._record.channel_info, layer._channels)
        channels = [
            _parse_array(data.get_data(width, height, depth, version), depth)
            for info, data in iterator
            if condition(info) and len(data.data) > 0
        ]
        if len(channels) and channels[0].size > 0:
            result = np.stack(channels, axis=1).reshape((height, width, -1))
            expected_channels = EXPECTED_CHANNELS.get(layer._psd.color_mode)
            if result.shape[2] > expected_channels:
                logger.debug('Extra channel found')
                return result[:, :, :expected_channels]
            return result
        return None
    if channel == 'color':
        return _find_channel(
            layer, layer.width, layer.height, lambda x: x.id >= 0
        )
    elif channel == 'shape':
        return _find_channel(
            layer, layer.width, layer.height,
            lambda x: x.id == ChannelID.TRANSPARENCY_MASK
        )
    elif channel == 'mask':
        if layer.mask._has_real() and real_mask:
            channel_id = ChannelID.REAL_USER_LAYER_MASK
        else:
            channel_id = ChannelID.USER_LAYER_MASK
        return _find_channel(
            layer, layer.mask.width, layer.mask.height,
            lambda x: x.id == channel_id
        )
    color = _find_channel(
        layer, layer.width, layer.height, lambda x: x.id >= 0
    )
    shape = _find_channel(
        layer, layer.width, layer.height,
        lambda x: x.id == ChannelID.TRANSPARENCY_MASK
    )
    if shape is None:
        return color
    return np.concatenate([color, shape], axis=2)