Copied O(n) implementation of getElementById from manakai DOM