@jdm: ping
Have some problems, 
first, In get_before_node and get_after_node, there are cases which exist None for ldw. for example, text node for head element. 
second, When use and_then, error occur to move out.