def first(self)"""return the first position in the tree (or none if empty""return self subtree first position(self root)if len(self else none def last(self)"""return the last position in the tree (or none if empty""return self subtree last position(self root)if len(self else none def before(selfp)"""return the position just before in the natural order return none if is the first position ""inherited from linkedbinarytree self validate(pif self left( )return self subtree last position(self left( )elsewalk upward walk above self parent(walkwhile above is not none and walk =self left(above)walk above above self parent(walkreturn above def after(selfp)"""return the position just after in the natural order return none if is the last position ""symmetric to before(pdef find position(selfk)"""return position with key kor else neighbor (or none if empty""if self is empty)return none elsep self subtree search(self root)khook for balanced tree subclasses self rebalance access(preturn code fragment navigational methods of the treemap class