class BotsingRawControlFlowGraph extends RawControlFlowGraph {

    @Override
    public BasicBlock determineBasicBlockFor(BytecodeInstruction instruction) {
        if (instruction == null) {
            throw new IllegalArgumentException("The given bytecode instruction is null");
        }

        List<BytecodeInstruction> blockNodes = new ArrayList<BytecodeInstruction>();
        blockNodes.add(instruction);

        Set<BytecodeInstruction> handledChildren = new HashSet<BytecodeInstruction>();
        Set<BytecodeInstruction> handledParents = new HashSet<BytecodeInstruction>();

        Queue<BytecodeInstruction> queue = new LinkedList<BytecodeInstruction>();
        queue.add(instruction);
        while (!queue.isEmpty()) {
            BytecodeInstruction currentInstruction = queue.poll();
            // Add examined child
            // it should be only one child
            if (outDegreeOf(currentInstruction) == 1) {
                BytecodeInstruction child = getChildren(currentInstruction).iterator().next();
                if (!blockNodes.contains(child) && !handledChildren.contains(child)) {
                    handledChildren.add(child);
                    if (inDegreeOf(child) < 2) {
                        blockNodes.add(blockNodes.indexOf(currentInstruction) + 1, child);
                        queue.add(child);
                    }
                }
            }

            // Add examined child
            // it should be only one parent
            if (inDegreeOf(currentInstruction) == 1) {
                BytecodeInstruction parent = getParents(currentInstruction).iterator().next();
                if (!blockNodes.contains(parent) && !handledParents.contains(parent)) {
                    handledParents.add(parent);
                    if (outDegreeOf(parent) < 2) {
                        // insert parent before current
                        blockNodes.add(blockNodes.indexOf(currentInstruction), parent);
                        queue.add(parent);
                    }
                }
            }
        }
        InterproceduralBasicBlock basicBlock = new InterproceduralBasicBlock(this.getClassLoader(),this.className,this.methodName,blockNodes);
        LOG.debug("Created basic block: {}",basicBlock.toString());
        return basicBlock;
    }

    public  BotsingRawControlFlowGraph(ClassLoader classLoader, String className, String methodName, int access);

}