py/repl: Refactor autocomplete, extracting reusable parts.
py/repl: Refactor autocomplete, extracting reusable parts.

Originally at adafruit#4548

Signed-off-by: Artyom Skrobov <693aba6df14163c66fe42c2bf2ee42ab22fb0513@gmail.com>

pfalcon/micropython,pfalcon/micropython,pfalcon/micropython,pfalcon/micropython,pfalcon/micropython