Use avl_tree directly instead of wal_flush_items

this makes the wal_flush reusable and is needed change for
the in-memory snapshot

Change-Id: I6d16120632ae1c2567ee2baa925f0a94ba59a637