public static BlockNode makeNodeWithStack(Long blockID) { if (isNullBlockInstance(blockID)) { return null; } Block block = Block.getBlock(blockID); String genus = block.getGenusName(); String parentGenus = block instanceof BlockStub ? ((BlockStub) block).getParentGenus() : null; String label; if (!block.labelMustBeUnique() || block instanceof BlockStub) { label = block.getBlockLabel(); } else { label = null; } BlockNode node = new BlockNode(genus, parentGenus, label); for (BlockConnector socket : block.getSockets()) { if (socket.hasBlock()) { node.addChild(makeNodeWithStack(socket.getBlockID())); } } if (block.hasAfterConnector()) { node.setAfter(makeNodeWithStack(block.getAfterBlockID())); } return node; }