Extract leaves from a binary tree and put them in a doubly linked list
Logic for trimming original tree is also added