public ArrayList<BedFeature> getBedData(RPChromosomeRegion selectionRegion,
                                                boolean contained) {
        int itemNumber = 0;
        int chromID, chromStart, chromEnd;
        String restOfFields;
        int itemHitValue;

        // chromID + chromStart + chromEnd + rest 0 byte
        // 0 byte for "restOfFields" is always present for bed data
        int minItemSize = 3 * 4 + 1;

        // allocate the bed feature array list
        bedFeatureList = new ArrayList<BedFeature>();

        // check if all leaf items are selection hits
        RPChromosomeRegion itemRegion = new RPChromosomeRegion( leafHitItem.getChromosomeBounds());
        int leafHitValue = itemRegion.compareRegions(selectionRegion);
        
        try {
            for(int index = 0; remDataSize > 0; ++index) {
                itemNumber = index + 1;

                // read in BigBed item fields - BBFile Table I
                if(isLowToHigh){
                    chromID = lbdis.readInt();
                    chromStart= lbdis.readInt();
                    chromEnd = lbdis.readInt();
                    restOfFields = lbdis.readString();
                }
                else{
                    chromID = dis.readInt();
                    chromStart= dis.readInt();
                    chromEnd = dis.readInt();
                    restOfFields = dis.readUTF();
                }

                if(leafHitValue == 0) {     // contained leaf region items always added
                    String chromosome = chromosomeMap.get(chromID);
                    BedFeature bbItem = new BedFeature(itemNumber, chromosome,
                         chromStart, chromEnd, restOfFields);
                    bedFeatureList.add(bbItem);
                }
                else {                      // test for hit
                    itemRegion = new RPChromosomeRegion(chromID, chromStart, chromID, chromEnd);
                    itemHitValue = itemRegion.compareRegions(selectionRegion);

                    // abs(itemHitValue) == 1 for intersection; itemHitValue == 0 for contained
                    if(!contained && Math.abs(itemHitValue) < 2 ||
                            itemHitValue == 0) {
                        // add bed feature to item selection list
                        String chromosome = chromosomeMap.get(chromID);
                        BedFeature bbItem = new BedFeature(itemNumber, chromosome,
                             chromStart, chromEnd, restOfFields);
                        bedFeatureList.add(bbItem);
                    }
                }

                // compute data block remainder from size of item read
                // todo: check that restOfFields.length() does not also include 0 byte terminator
                remDataSize -= minItemSize + restOfFields.length();
            }

        }catch(IOException ex) {
            log.error("Read error for Bed data item " + itemNumber);

            // accept this as an end of block condition unless no items were read
            if(itemNumber == 1)
                throw new RuntimeException("Read error for Bed data item " + itemNumber);
        }

        return bedFeatureList;
    }