Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
In previous implementation one excess element could be added to the chain. Add previous sibling presence check to prevent this. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>