added breadth first search and an avl tree for visited position lookups