@Override
    public void initTreeTraversal(){
        try
        {
            if(memory != null)
            {
                memory.rewind();
                return;
            }
            if(in != null)
            {
                in.close();
            }
            
            in = new BufferedInputStream(new FileInputStream(file));
            // Read the size of the nodes (size of the nodes is stored in the last
            // byte of the preamble
            b = new byte[3];
            in.read(b);
            // Get Link type info
            type = b[0];
            // Create a buffer with the appropriate size
            b = new byte[b[2]];
            if(fromMemory)
            {
                File F = new File(file);
                int fs = (int)(F.length()-3);
                System.out.println("allocating byte buffer of size: " + fs);
                memory = ByteBuffer.allocateDirect(fs);
                System.out.println("Reading file contents");
                while(in.read(b) == b.length)
                {
                    memory.put(b);
                }
                System.out.println("Done");
                memory.rewind();
            }
            
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }