Fixing issue when Element is used as selector
Slight optimization by using previous/nextElementSibling when available